Assemble Remote speech before reader delivery

This commit is contained in:
ak47 committed 2026-11-04 14:33:54 -05:00
1 parent f23e89ed93
commit 205cb27483
9 files changed
+492 -33

No files matched your search

+23 -1
View File
@@ -12,6 +12,7 @@ import (
// Leave room for lease metadata inside the existing 8192-byte call bound.
const MaxRemoteSpeechBytes = 6144
const RemoteSpeechQueueSize = 64
const RemoteSpeechQueueBytes = 256 * 1024
// RemoteSpeechPart carries resolved character/language state for each fragment.
// End is an utterance boundary, not text. Whitespace is significant.
@@ -31,7 +32,28 @@ type RemoteSpeech struct {
type RemotePresentation struct {
RemoteOperation
Speech RemoteSpeech `json:"speech"`
Speech RemoteSpeech `json:"speech"`
Utterance uint64 `json:"utterance,omitempty"` // First fragment's operation sequence.
Final bool `json:"final,omitempty"`
}
// A zero utterance is a complete, single-call effect. A nonzero utterance
// stages speak fragments until Final; the reader admits them as one delivery.
func ValidRemotePresentation(request RemotePresentation) bool {
return len(request.Lease) == 32 && request.Epoch != 0 && request.Sequence != 0 &&
ValidRemoteSpeech(request.Speech) &&
(request.Utterance == 0 && !request.Final ||
request.Utterance > 0 && request.Utterance <= request.Sequence && request.Speech.Kind == "speak")
}
func (request *RemotePresentation) UnmarshalJSON(data []byte) error {
type plain RemotePresentation
var value plain
if reject_speech_nulls(data) != nil || DecodeStrict(data, &value) != nil || !ValidRemotePresentation(RemotePresentation(value)) {
return ErrProtocol
}
*request = RemotePresentation(value)
return nil
}
func reject_speech_nulls(data []byte) error {