Skip to content
English

KnowledgePublicationOptions ​

KIT · interface · 类型合同

App-owned guards, store and limits for a publication workflow.

导入 ​

ts
import type { KnowledgePublicationOptions } from '@jangts/agent-core/kits/knowledge';
js
/** @typedef {import('@jangts/agent-core/kits/knowledge').KnowledgePublicationOptions} KnowledgePublicationOptions */

其他公开入口:@jangts/agent-core/types、@jangts/agent-core/structs、@jangts/agent-core/kits/knowledge、@jangts/agent-core/kits。

定义 ​

ts
interface KnowledgePublicationOptions<App>

泛型参数 ​

类型参数约束默认类型
App——

字段结构 ​

字段类型必需说明
storeKnowledgePublicationStore必需只读。见类型定义及调用场景。
requiredReadsreadonly KnowledgeRead[] | undefined可省略只读。Reads that must succeed against every compiled document set, proving sections still exist.
maxReadCharsnumber | undefined可省略只读。Per-read character budget applied by the catalog compiler.
maxCandidatesnumber | undefined可省略只读。Maximum pending candidates retained; defaults to 32 and must be a positive integer.
candidateRetentionMsnumber | undefined可省略只读。Candidate retention window; defaults to seven days.
now(() => number) | undefined可省略只读。Clock override for timestamps and expiry; defaults to Date.now.
authorize(operation: (typeof knowledgePublicationOperations)[number], context: OperationContext<App>) => MaybePromise<void>必需Guards one operation before any read or write.
verifySources(sources: readonly KnowledgeSourceReference[], context: OperationContext<App>) => MaybePromise<void>必需Validate real provenance/revisions/visibility. A model's source list is not a grant.

成员目录 ​

成员用途
authorizeGuards one operation before any read or write.
verifySourcesValidate real provenance/revisions/visibility. A model's source list is not a grant.

成员详情 ​

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.

参数类型传递说明
operation"reject" | "propose" | "publish"必需—
contextOperationContext<App>必需—
context 的字段
字段类型必需说明
appunknown extends App ? App : Readonly<App>必需只读。见类型定义及调用场景。
loggerSubFlowLog | undefined可省略只读。Explicit optional recorder for this operation; never inferred from diagnostics.
signalAbortSignal必需只读。Non-optional cancellation signal; never undefined once execution has started.
diagnosticsDiagnosticContext | undefined可省略只读。Diagnostic scope of the enclosing call, when recording is enabled.

返回: MaybePromise<void>。

等待后的值: 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.

参数类型传递说明
sourcesreadonly KnowledgeSourceReference[]必需—
contextOperationContext<App>必需—
context 的字段
字段类型必需说明
appunknown extends App ? App : Readonly<App>必需只读。见类型定义及调用场景。
loggerSubFlowLog | undefined可省略只读。Explicit optional recorder for this operation; never inferred from diagnostics.
signalAbortSignal必需只读。Non-optional cancellation signal; never undefined once execution has started.
diagnosticsDiagnosticContext | undefined可省略只读。Diagnostic scope of the enclosing call, when recording is enabled.

返回: MaybePromise<void>。

等待后的值: void。

使用示例 ​

先读取一份普通对象资料 ​

入门 · 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);

在相同 read 上增加章节与预算 ​

配置 · 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);

相关策略源码 ​

相关定义 ​

接口参考、使用示例与开发指南。