main => prod#365
Merged
dariusz-did merged 6 commits intoprodfrom Apr 21, 2026
Merged
Conversation
chore: upgrade Node.js from 20 to 22
The first assistant turn of a session (an unsolicited greeting) was being dropped because processChatEvent's message-creation branch only fired when the last message was a transcribed user turn. With an empty message list, every partial and answer hit the fallback early return and the greeting never appeared in the UI. Broaden the creation branch to also fire when there is no last message. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat: add message.parts — structured content representation Add MessagePart type and optional parts field to Message interface. Create content-parser utility that parses markdown content (images, videos, links, HTML anchors) into typed MessagePart arrays. Integrate parser into all message construction paths: - Streaming pipeline (processChatEvent partials + answers) - Audio transcription (handleAudioTranscribedMessage) - REST chat (user message + assistant response) - Speak (assistant message) Export parseMessageParts utility and MessagePart type from SDK public API for consumer use. * fix: harden regexes against ReDoS (CodeQL polynomial backtracking) Restrict character classes to prevent catastrophic backtracking: - Alt text: [^\]* → [^\[\]]* (disallow nested brackets) - URLs: [^)]+ → [^)\s]+ (disallow whitespace in URLs) - HTML attrs: [^>]* → [^>]*? (lazy quantifier) * style: fix prettier formatting * refactor: use parseMessagePartsMemo consistently across internal SDK code Unify message parsing calls inside the SDK on the memoized variant. The non-memo parseMessageParts remains the public API export for consumers.
Change Message.parts from optional to required so consumers can rely on it without defensive fallbacks. This closes a narrow contract gap where the SDK briefly pushes a Message into items.messages before the first content chunk arrives, leaving parts undefined. Initialize parts: [] in the only construction site that lacked it (streaming assistant message in message-queue.ts). All other paths already populated parts via parseMessagePartsMemo. This is a type-level tightening matching the actual runtime contract.
dor-eitan
approved these changes
Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Type
🔮 Feature
🐛 BugFix
⚒️ Refactor
🧹 Chore
🔥 HotFix
🚀 Release
Description
Reference Links