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
+3 -19
View File
@@ -11,7 +11,6 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { setTimeout as delay } from 'node:timers/promises'
import { fileURLToPath } from 'node:url'
import { decodeStorageRecord } from '@deepseek-ai/dsh-session/chunk-rows'
import { describe, expect, it } from 'vitest'
import WebSocket from 'ws'
@@ -60,10 +59,7 @@ interface WorkspaceBaseline {
}
interface HistoryPage {
records: Array<
| { type: 'event'; event: HistoryEvent }
| { type: 'chunks'; event: HistoryChunkEvent }
>
records: Array<{ type: 'event'; event: HistoryEvent }>
hasMore: boolean
}
@@ -72,11 +68,6 @@ interface HistoryEvent {
data: unknown
}
interface HistoryChunkEvent extends HistoryEvent {
seq: number
time: number
}
interface ProcessObservation {
readonly ready: Promise<string>
readonly text: () => string
@@ -314,16 +305,9 @@ function assistantText(page: HistoryPage): string {
return text.join('\n')
}
/** Expand lossless history records for assertions over the public event stream. */
/** Read scalar v2 history records for assertions over the public event stream. */
function historyEvents(page: HistoryPage): HistoryEvent[] {
return page.records.flatMap(record => record.type === 'event'
? [record.event]
: decodeStorageRecord({
type: record.event.type.replace(/^chunkrow\//u, ''),
seq0: record.event.seq,
time0: record.event.time,
data: record.event.data,
}))
return page.records.map(record => record.event)
}
/** Stop the spawned CLI through its normal signal path, escalating only on a stuck teardown. */