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 textBlock: TextContent | undefined
let currentTextIdx = -1
let thinkingBlock: string[] = []
let thinkingIdx = -1
let finished = false
const abortUpstream = () => {
@@ -204,30 +204,19 @@ export function createStreamCommandCode(deps: CoreDependencies) {
currentTextIdx = -1
}
const flushThinkingBlock = () => {
if (thinkingBlock.length === 0) return
const thinkingText = thinkingBlock.join("")
thinkingBlock = []
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,
})
const endThinking = () => {
if (thinkingIdx < 0) return
const tc = output.content[thinkingIdx]
if (tc && tc.type === "thinking") {
stream.push({
type: "thinking_end",
contentIndex: idx,
content: thinkingText,
contentIndex: thinkingIdx,
content: (tc as { thinking: string }).thinking,
partial: output,
})
}
thinkingIdx = -1
}
const handleEvent = (event: unknown) => {
if (!isRecord(event)) return
@@ -262,12 +251,32 @@ export function createStreamCommandCode(deps: CoreDependencies) {
case "reasoning-delta": {
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
}
case "reasoning-end": {
flushThinkingBlock()
endThinking()
break
}
@@ -436,7 +445,7 @@ export function createStreamCommandCode(deps: CoreDependencies) {
}
endTextBlock()
flushThinkingBlock()
endThinking()
stream.push({
type: "done",