ReplyDeliveryOptions
KIT · interface · Type contract
Host-controlled delivery of already validated text; not upstream model generation.
Import
ts
import type { ReplyDeliveryOptions } from '@jangts/agent-core/events';1
js
/** @typedef {import('@jangts/agent-core/events').ReplyDeliveryOptions} ReplyDeliveryOptions */1
Other public entry points:@jangts/agent-core, @jangts/agent-core/types, @jangts/agent-core/structs, @jangts/agent-core/events, @jangts/agent-core/kits/presentation, @jangts/agent-core/kits.
Definition
ts
interface ReplyDeliveryOptions1
Field structure
| Field | Type | Required | Description |
|---|---|---|---|
chunkSize | number | undefined | Optional | Characters per emitted text event; defaults to 240 and must be a positive integer. |
intervalMs | number | undefined | Optional | Delay between chunks in milliseconds; defaults to 0. |
bubblePauseMs | number | undefined | Optional | Delay between bubbles in milliseconds; defaults to 0. |
maxDurationMs | number | undefined | Optional | Upper bound on intentional pacing time; backpressure and network time are independent. |
Examples
- Reply events: text chunks and bubble boundaries: Turn an accepted reply into awaitable text/bubble events while preserving cancellation and delivery backpressure.
First output a reply that is already accepted
Beginner · Node.js
ts
import { Presentation } from '@jangts/agent-core/kits/presentation';
const context = { signal: new AbortController().signal };
for await (const event of Presentation.publishReplyEvents({ text: '这是已经接受的答复。' }, context)) console.log(event);1
2
3
2
3
js
import { Presentation } from '@jangts/agent-core/kits/presentation';
const context = { signal: new AbortController().signal };
for await (const event of Presentation.publishReplyEvents({ text: '这是已经接受的答复。' }, context))
console.log(event);1
2
3
4
2
3
4
Add chunking and bubbles to the same event entry
Configuration · Node.js
ts
import { Presentation } from '@jangts/agent-core/kits/presentation';
const text = Presentation.replyBubbleTexts({ text: '先说明定义。', bubbles: ['再解释输入输出。'] }).join(Presentation.REPLY_BUBBLE_BOUNDARY);
const events = Presentation.publishReplyEvents({ text, delivery: { chunkSize: 6, intervalMs: 10, bubblePauseMs: 30, maxDurationMs: 1000 } }, { signal: new AbortController().signal });
for await (const event of events) {
if (event.type === 'text') process.stdout.write(event.text);
else if (event.type === 'bubble') process.stdout.write('\n');
}1
2
3
4
5
6
7
2
3
4
5
6
7
js
import { Presentation } from '@jangts/agent-core/kits/presentation';
const text = Presentation.replyBubbleTexts({ text: '先说明定义。', bubbles: ['再解释输入输出。'] }).join(Presentation.REPLY_BUBBLE_BOUNDARY);
const events = Presentation.publishReplyEvents({ text, delivery: { chunkSize: 6, intervalMs: 10, bubblePauseMs: 30, maxDurationMs: 1000 } }, { signal: new AbortController().signal });
for await (const event of events) {
if (event.type === 'text')
process.stdout.write(event.text);
else if (event.type === 'bubble')
process.stdout.write('\n');
}1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9