@hienlh/ppm 0.5.12 → 0.5.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/package.json +1 -1
- package/src/providers/claude-agent-sdk.ts +30 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.5.13] - 2026-03-18
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- **Windows: simulated token streaming** — CLI `stream-json` only emits complete `assistant` messages (no per-token deltas). Now synthesizes `stream_event` / `content_block_delta` events in ~30-char chunks so FE gets smooth typing effect instead of all text appearing at once
|
|
7
|
+
|
|
3
8
|
## [0.5.12] - 2026-03-18
|
|
4
9
|
|
|
5
10
|
### Fixed
|
package/package.json
CHANGED
|
@@ -151,6 +151,36 @@ export class ClaudeAgentSdkProvider implements AIProvider {
|
|
|
151
151
|
if (!trimmed) continue;
|
|
152
152
|
try {
|
|
153
153
|
const event = JSON.parse(trimmed);
|
|
154
|
+
// CLI stream-json doesn't emit per-token stream_event deltas — it sends
|
|
155
|
+
// complete assistant messages. Synthesize stream_event deltas so the FE
|
|
156
|
+
// gets a smooth streaming experience (same as SDK with includePartialMessages).
|
|
157
|
+
if (event.type === "assistant" && event.message?.content) {
|
|
158
|
+
for (const block of event.message.content) {
|
|
159
|
+
if (block.type === "text" && block.text) {
|
|
160
|
+
// Emit text in ~30-char chunks as synthetic stream_event deltas
|
|
161
|
+
const text = block.text as string;
|
|
162
|
+
const CHUNK = 30;
|
|
163
|
+
for (let i = 0; i < text.length; i += CHUNK) {
|
|
164
|
+
yield {
|
|
165
|
+
type: "stream_event",
|
|
166
|
+
event: {
|
|
167
|
+
type: "content_block_delta",
|
|
168
|
+
delta: { type: "text_delta", text: text.slice(i, i + CHUNK) },
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
} else if (block.type === "thinking" && block.thinking) {
|
|
173
|
+
yield {
|
|
174
|
+
type: "stream_event",
|
|
175
|
+
event: {
|
|
176
|
+
type: "content_block_delta",
|
|
177
|
+
delta: { type: "thinking_delta", thinking: block.thinking },
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// Always yield the original event too (for init, result, rate_limit, etc.)
|
|
154
184
|
yield event;
|
|
155
185
|
} catch {
|
|
156
186
|
// Skip non-JSON lines (e.g. progress indicators)
|