Skip to content
中文

ReplyPreviewOptions ​

SUPPORT · interface · Type contract

Settings for createReplyPreview; sink receives every bubble list and is required.

Import ​

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

Other public entry points:@jangts/agent-core/support.

Definition ​

ts
interface ReplyPreviewOptions

Extends or implements: ReplyPreviewSettings.

Field structure ​

FieldTypeRequiredDescription
sink(bubbles: string[]) => void | Promise<void>RequiredRead-only. Receives the current bubble list; rejection propagates to the event caller.
rulesreadonly ReplyPreviewRule[]RequiredSee the type definition and usage context.
render((text: string) => string) | undefinedOptionalPresentation only; must not authorize, persist or execute a proposal.
maxCharsnumber | undefinedOptionalStreamed characters tolerated before preview is disabled; default 16000.

Member index ​

MemberPurpose
sinkReceives the current bubble list; rejection propagates to the event caller.

Member details ​

sink ​

Receives the current bubble list; rejection propagates to the event caller.

ts
ReplyPreviewOptions.sink(bubbles: string[]): void | Promise<void>
ParameterTypePassingDescription
bubblesstring[]Required—

Returns: void \| Promise<void>.

Awaited value: void.

Examples ​

Add a preview for a plain-text stage ​

Beginner · Node.js

ts
import { ModelRunner, Support } from '@jangts/agent-core';
const preview = Support.createReplyPreview({ rules: [{ stageId: 'reply' }],
  sink: bubbles => { console.log('preview', bubbles); },
});
const runner = new ModelRunner({ provider: { async *stream() { yield '你好'; yield ',Core'; } }, sink: { output: preview } });
console.log((await runner.invoke({ input: '你好', stageId: 'reply' })).value);
js
import { ModelRunner, Support } from '@jangts/agent-core';
const preview = Support.createReplyPreview({ rules: [{ stageId: 'reply' }],
    sink: bubbles => { console.log('preview', bubbles); },
});
const runner = new ModelRunner({ provider: { async *stream() { yield '你好'; yield ',Core'; } }, sink: { output: preview } });
console.log((await runner.invoke({ input: '你好', stageId: 'reply' })).value);

Allow only displayable fields of an explicit body protocol ​

Configuration · Node.js

Rules must correspond to the reply tool and Schema the App actually registers; configuring a preview does not create a model tool.

ts
import { Support } from '@jangts/agent-core';
const preview = Support.createReplyPreview({
  rules: [{ stageId: 'reply', toolId: 'reply', paths: [['answer'], ['bubbles', '*']],
    when: { path: ['kind'], values: ['reply'] } }],
  sink: async bubbles => { console.log('当前暂态正文', bubbles); },
  maxChars: 4000,
});
console.log(typeof preview);
js
import { Support } from '@jangts/agent-core';
const preview = Support.createReplyPreview({
    rules: [{ stageId: 'reply', toolId: 'reply', paths: [['answer'], ['bubbles', '*']],
            when: { path: ['kind'], values: ['reply'] } }],
    sink: async (bubbles) => { console.log('当前暂态正文', bubbles); },
    maxChars: 4000,
});
console.log(typeof preview);

API reference, usage examples and developer guides.