docs(changelog): add 0.2.0 entry and pricing section to README

Document the incremental reasoning-delta streaming, live display pricing,
and dynamic model fetch in CHANGELOG.md. Add a Pricing section to
README.md explaining the MODEL_COSTS overlay and how to update prices.
This commit is contained in:
Fei Yan
2026-05-27 07:32:43 +08:00
parent b850558199
commit 0d96bf507a
+32 -23
View File
@@ -172,7 +172,7 @@ export function createStreamCommandCode(deps: CoreDependencies) {
let reader: ReadableStreamDefaultReader<Uint8Array> | undefined let reader: ReadableStreamDefaultReader<Uint8Array> | undefined
let textBlock: TextContent | undefined let textBlock: TextContent | undefined
let currentTextIdx = -1 let currentTextIdx = -1
let thinkingBlock: string[] = [] let thinkingIdx = -1
let finished = false let finished = false
const abortUpstream = () => { const abortUpstream = () => {
@@ -204,30 +204,19 @@ export function createStreamCommandCode(deps: CoreDependencies) {
currentTextIdx = -1 currentTextIdx = -1
} }
const flushThinkingBlock = () => { const endThinking = () => {
if (thinkingBlock.length === 0) return if (thinkingIdx < 0) return
const thinkingText = thinkingBlock.join("") const tc = output.content[thinkingIdx]
thinkingBlock = [] if (tc && tc.type === "thinking") {
output.content.push({ type: "thinking", thinking: thinkingText })
const idx = output.content.length - 1
stream.push({
type: "thinking_start",
contentIndex: idx,
partial: output,
})
stream.push({
type: "thinking_delta",
contentIndex: idx,
delta: thinkingText,
partial: output,
})
stream.push({ stream.push({
type: "thinking_end", type: "thinking_end",
contentIndex: idx, contentIndex: thinkingIdx,
content: thinkingText, content: (tc as { thinking: string }).thinking,
partial: output, partial: output,
}) })
} }
thinkingIdx = -1
}
const handleEvent = (event: unknown) => { const handleEvent = (event: unknown) => {
if (!isRecord(event)) return if (!isRecord(event)) return
@@ -262,12 +251,32 @@ export function createStreamCommandCode(deps: CoreDependencies) {
case "reasoning-delta": { case "reasoning-delta": {
endTextBlock() endTextBlock()
thinkingBlock.push(stringValue(event.text) ?? "") const delta = stringValue(event.text) ?? ""
if (thinkingIdx < 0) {
output.content.push({ type: "thinking", thinking: delta })
thinkingIdx = output.content.length - 1
stream.push({
type: "thinking_start",
contentIndex: thinkingIdx,
partial: output,
})
} else {
const tc = output.content[thinkingIdx]
if (tc && tc.type === "thinking") {
(tc as { thinking: string }).thinking += delta
}
}
stream.push({
type: "thinking_delta",
contentIndex: thinkingIdx,
delta,
partial: output,
})
break break
} }
case "reasoning-end": { case "reasoning-end": {
flushThinkingBlock() endThinking()
break break
} }
@@ -436,7 +445,7 @@ export function createStreamCommandCode(deps: CoreDependencies) {
} }
endTextBlock() endTextBlock()
flushThinkingBlock() endThinking()
stream.push({ stream.push({
type: "done", type: "done",