ReplyPreviewStage
SUPPORT · interface · 类型合同
Stage declaration: which tools it exposes and whether it previews text or arguments.
导入
ts
import type { ReplyPreviewStage } from '@jangts/agent-core/support';js
/** @typedef {import('@jangts/agent-core/support').ReplyPreviewStage} ReplyPreviewStage */其他公开入口:@jangts/agent-core/support、@jangts/agent-core/support/model。
定义
ts
interface ReplyPreviewStage字段结构
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
id | string | 必需 | 只读。Stage ID used by the workflow and transport projection. |
toolIds | readonly string[] | undefined | 可省略 | 只读。Capabilities exposed at this stage; must be unique and registered. |
preview | "tools" | "text" | undefined | 可省略 | 只读。text previews plain model text; tools previews opted-in capability arguments. |
使用示例
- 从 Tool 与阶段声明生成预览规则:复用实际 Schema 与阶段引用,只为明确允许展示的 Tool 生成规则。
明确标记纯文本阶段
入门 · 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);