Skip to content
English

ReplyPreviewTool ​

SUPPORT · interface · 类型合同

Capability declaration used to derive preview rules.

Omitted preview means the capability never previews, so previewing is an explicit opt-in.

导入 ​

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

其他公开入口:@jangts/agent-core/support、@jangts/agent-core/support/model。

定义 ​

ts
interface ReplyPreviewTool

字段结构 ​

字段类型必需说明
idstring必需只读。Capability ID, which must equal the native function wire name used for transport.
jsonSchemaReadonly<Record<string, unknown>>必需只读。Input schema used to prove that preview and eligibility paths really exist.
previewtrue | Omit<ReplyPreviewRule, "stageId" | "toolId"> | undefined可省略只读。Explicit preview opt-in: true uses the default text/bubble paths, an object narrows the paths and eligibility, and omission means the capability never previews.

使用示例 ​

明确标记纯文本阶段 ​

入门 · Node.js

ts
import { Support } from '@jangts/agent-core';
const rules = Support.createReplyPreviewRules({ stages: [{ id: 'reply', preview: 'text' }], tools: [] });
const preview = Support.createReplyPreview({ rules, sink: bubbles => { console.log(bubbles); } });
console.log(typeof preview);
js
import { Support } from '@jangts/agent-core';
const rules = Support.createReplyPreviewRules({ stages: [{ id: 'reply', preview: 'text' }], tools: [] });
const preview = Support.createReplyPreview({ rules, sink: bubbles => { console.log(bubbles); } });
console.log(typeof preview);

复用结构化 Tool 的 Schema 与阶段引用 ​

配置 · Node.js

真实 App 应从它已经登记的 Tool 和阶段声明投影这两个数组;本例用最小静态资料展示所需字段。

ts
import { Support } from '@jangts/agent-core';
const tools = [{ id: 'reply', jsonSchema: { type: 'object', properties: { answer: { type: 'string' } } },
  preview: { paths: [['answer']] } }];
const rules = Support.createReplyPreviewRules({
  stages: [{ id: 'respond', toolIds: ['reply'], preview: 'tools' }], tools,
});
const preview = Support.createReplyPreview({ rules, sink: bubbles => { console.log(bubbles); } });
console.log(rules, typeof preview);
js
import { Support } from '@jangts/agent-core';
const tools = [{ id: 'reply', jsonSchema: { type: 'object', properties: { answer: { type: 'string' } } },
        preview: { paths: [['answer']] } }];
const rules = Support.createReplyPreviewRules({
    stages: [{ id: 'respond', toolIds: ['reply'], preview: 'tools' }], tools,
});
const preview = Support.createReplyPreview({ rules, sink: bubbles => { console.log(bubbles); } });
console.log(rules, typeof preview);

相关策略源码 ​

相关定义 ​

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