Skip to content

main => prod#365

Merged
dariusz-did merged 6 commits intoprodfrom
main
Apr 21, 2026
Merged

main => prod#365
dariusz-did merged 6 commits intoprodfrom
main

Conversation

@dariusz-did
Copy link
Copy Markdown
Contributor

Pull Request Type

🔮 Feature
🐛 BugFix
⚒️ Refactor
🧹 Chore
🔥 HotFix
🚀 Release

Description

Reference Links

dor-eitan and others added 4 commits April 15, 2026 15:45
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.
@dariusz-did dariusz-did merged commit c57af40 into prod Apr 21, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants