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';1
js
/** @typedef {import('@jangts/agent-core/support').ReplyPreviewOptions} ReplyPreviewOptions */1
Other public entry points:@jangts/agent-core/support.
Definition
ts
interface ReplyPreviewOptions1
Extends or implements: ReplyPreviewSettings.
Field structure
| Field | Type | Required | Description |
|---|---|---|---|
sink | (bubbles: string[]) => void | Promise<void> | Required | Read-only. Receives the current bubble list; rejection propagates to the event caller. |
rules | readonly ReplyPreviewRule[] | Required | See the type definition and usage context. |
render | ((text: string) => string) | undefined | Optional | Presentation only; must not authorize, persist or execute a proposal. |
maxChars | number | undefined | Optional | Streamed characters tolerated before preview is disabled; default 16000. |
Member index
| Member | Purpose |
|---|---|
sink | Receives 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>1
| Parameter | Type | Passing | Description |
|---|---|---|---|
bubbles | string[] | Required | — |
Returns: void \| Promise<void>.
Awaited value: void.
Examples
- Body preview: ordered output is not final acceptance: Extract displayable body text by registered stage/tool/field path, and refuse to treat control proposals as executed results.
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);1
2
3
4
5
6
2
3
4
5
6
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);1
2
3
4
5
6
2
3
4
5
6
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);1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
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);1
2
3
4
5
6
7
8
2
3
4
5
6
7
8