feat(session)!: embed assistant streams in format v2

This commit is contained in:
Tianyi Cui
2026-09-02 04:00:01 +08:00
parent 0bb7bba015
commit f99b06eaed
387 changed files with 9491 additions and 4625 deletions
@@ -83,6 +83,7 @@ function appendConversation(session: Session): void {
const oldAssistant = session.append(
'assistant/message',
{
stream: [],
turn: 1,
step: 1,
message: createMessage({
@@ -152,6 +153,7 @@ function appendConversation(session: Session): void {
session.append(
'assistant/message',
{
stream: [],
turn: 2,
step: 1,
message: createMessage({
@@ -190,6 +192,7 @@ function appendConversation(session: Session): void {
session.append(
'assistant/message',
{
stream: [],
turn: 2,
step: 2,
message: createMessage({
@@ -203,10 +206,16 @@ function appendConversation(session: Session): void {
},
{ surfaceOp: 'append' },
)
session.append('assistant/chunk', {
session.append('assistant/attempt', {
turn: 2,
step: 2,
chunk: { type: 'text-delta', index: 0, text: 'unfinished answer' },
stream: [{
type: 'text-chunks',
time0: 0,
index: 0,
dt: [],
texts: ['unfinished answer'],
}],
})
}
@@ -704,6 +713,7 @@ describe('session reference discovery and preparation', () => {
source.append(
'assistant/message',
{
stream: [],
turn: 3,
step: 1,
message: createMessage({
@@ -805,6 +815,7 @@ describe('session reference discovery and preparation', () => {
const later = source.append(
'assistant/message',
{
stream: [],
turn: 1,
step: 1,
message: createMessage({