Repository navigation
fix(media): voice stream connects to the served URL; media types match the API - #63
Merged
Merged
Conversation
…h the API - Voice stream connects to /api/v1/safety/voice/stream, sends its initial config once the session is ready, sends context in the wire format (age_group, child_age, resolved platform), and supports video frames with frame_analysis events and visual alerts. - Voice, image, video and document uploads send incident_moderation_enabled. - Image and video take flagRiskTerms and return risk_terms; video takes analysisType and maxFrames; document accepts images and splitBySender. - Synthetic image, audio and video results use the field names the API returns; fileId is forwarded; bypassCache is deprecated as a no-op. - New verifyImageMatch() and getSafetyClassification(). - Type-level tests pin the result shapes. Closes #58
…e shape Synthetic image, audio and video results now list only the fields the API publishes: screenshot_detection carries is_screenshot and confidence, AudioStats carries the seven published measurements, and the forensic summary carries signal_count, sources and combined_confidence_boost. action_detail is deprecated on these results, as it is not part of their response. Type-level tests pin the exact key sets.
lena-sabadina
approved these changes
Nov 8, 2026
lena-sabadina
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed media and voice changes. Merged main in and unified SpeakerStance so the typecheck passes; CI is green and the full suite passes locally.
Merged
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.
What changes for users
Voice streaming works again.
voiceStream()connected to a URL the API does not serve, so sessions could not connect. It now connects to/api/v1/safety/voice/stream, and:ageGroupand the newchildAgenow take effect;platformis attributed like every other call;relationshipis deprecated, it was never read);enableVideoandframeIntervalSecondsin the config,sendVideoFrame()on the session, a newframe_analysisevent with anonFrameAnalysishandler, and alerts with categoryvisual;sendAudio()andsendVideoFrame()throw until the session is ready, instead of sending data the server would not read.Uploads
analyzeVoice,analyzeImage,analyzeVideoandanalyzeDocumentnow sendincident_moderation_enabled(it was accepted but never sent).analyzeImageandanalyzeVideotakeflagRiskTermsand returnrisk_terms.analyzeVideotakesanalysisTypeandmaxFrames.analyzeDocumentaccepts PNG, JPEG and WebP images as well as PDF, and takessplitBySenderfor messaging screenshots.file_idis always returned.VoiceAnalysisResultgainslanguageandlanguage_status.Synthetic content results now match what the API returns
semantic_analysis(visionwas never returned). Addsscreenshot_detection(is_screenshot,confidence),metadata,file_id.AudioStatsholds the seven published measurements (rms_level,rms_peak,dc_offset,dynamic_range,silence_ratio,peak_count,flat_factor). Addsmetadata,file_id. Transcriptionsegmentsis optional (absent when there is no speech).temporal_consistencyusesscore,identity_consistency,landmark_stability,anomalous_pairs. Addsdrift_signature,forensic_signals,language_status,metadata,file_id.signal_count,sources(name,signal_count,confidence_boost) andcombined_confidence_boost. These types follow the published response shape for these endpoints.fileIdis forwarded on synthetic image, audio and video.New methods
verifyImageMatch(): face match, age estimate, explicit-content and synthetic checks in one call (POST /api/v1/verify-image-match). Bytes are base64-encoded for you.getSafetyClassification(): the account's daily safety classification (GET /api/v1/safety-classification). An account with no classification yet answers{ exists: false }, never a zero score.Deprecated (kept, marked
@deprecated):bypassCache(no-op, there is no verdict cache),visionon synthetic image results,rms_mean, the oldtemporal_consistencyfield names andsignalson temporal and lip-sync results,action_detailon synthetic text, image, audio and video results and on document page results,detected_languageon document page results,incident_moderation_enabledon synthetic image, audio and video inputs (not read there), and voice streamcontext.relationship. ThegetSyntheticProfilenote now says the route was removed. The SDK no longer sendsbypass_cache.Tests
wsserver that, like the API, reads messages only afterready. It asserts the URL and path the client connects to, Bearer auth, the config message shape, the0x01video frame prefix andframe_analysisdispatch. No test reaches the network.vi.spyOn(global, 'fetch').tests/types/*.test-d.ts), whichnpx vitest runnow type-checks throughtsconfig.typecheck.json. A field name the API does not send passes every runtime test, so these pin the shapes.Before the fix (tests written first)
After the fix
Follow-up: synthetic results follow the published response shape
The synthetic image, audio and video types now list exactly the fields in the published response for those endpoints. Fields added earlier in this PR that are not part of it were removed (never released), and
action_detailis deprecated on these results. Type tests pin the exact key sets.Before:
After:
Full suite: 146 tests before this PR, 197 after.
npm run buildis clean.Closes #58