Documentation
¶
Overview ¶
Package perception turns the world into sparse, persistent text.
One mechanism generalises across every stream, and it is why video is an addition to this system rather than a second architecture:
An observer converts a continuous stream into sparse, persistent text appended to the trajectory, behind a gate that costs almost nothing and produces nothing on unchanged input.
The audio path was already this shape without naming it: an acoustic gate, buffered frames, a streaming recogniser, typed revisions, canonical observations. Naming it is what lets a video observer be a peer rather than a special case.
Two findings are binding constraints on the contract. Narration is the value, not keyframe selection - persistent text is what survives after images are pruned, so Observe returns text and images are an optional attachment referenced by handle. And components must be selected per model, because at least one strong model regresses when handed a keyframe stream through image-token dilution; so observers are independently switchable per session rather than bundled.
Index ¶
- Constants
- func CarriesSpeech(text string) bool
- type AudioConfig
- type AudioObserver
- func (observer *AudioObserver) Accepts(frame Frame) bool
- func (observer *AudioObserver) Cadence() time.Duration
- func (observer *AudioObserver) Close() error
- func (observer *AudioObserver) Dispose() error
- func (observer *AudioObserver) DurationMS() uint64
- func (observer *AudioObserver) EagerEndOfTurn() bool
- func (observer *AudioObserver) Flush(ctx context.Context) ([]Observation, error)
- func (observer *AudioObserver) Gate(Frame) bool
- func (observer *AudioObserver) Name() string
- func (observer *AudioObserver) Observe(ctx context.Context, frames []Frame) ([]Observation, error)
- func (observer *AudioObserver) Reset()
- func (observer *AudioObserver) SpeechEndpointed() bool
- type ComponentSpec
- type EnergyGate
- type Factory
- type Frame
- type FrameKind
- type GateConfig
- type GateResult
- type Image
- type ModelNarrator
- type Narrator
- type NarratorConfig
- type NarratorMetrics
- type Observation
- type Observer
- type ObserverSetSpec
- type RefreshableObserver
- type Retainer
- type Set
- type SourceRefreshableObserver
- type StaticNarrator
- type VideoConfig
- type VideoMetrics
- type VideoObserver
- func (observer *VideoObserver) Accepts(frame Frame) bool
- func (observer *VideoObserver) Cadence() time.Duration
- func (observer *VideoObserver) Flush(context.Context) ([]Observation, error)
- func (observer *VideoObserver) Gate(frame Frame) bool
- func (observer *VideoObserver) Metrics() VideoMetrics
- func (observer *VideoObserver) Name() string
- func (observer *VideoObserver) Observe(ctx context.Context, frames []Frame) ([]Observation, error)
- func (observer *VideoObserver) RefreshNext()
- func (observer *VideoObserver) RefreshSource(source string)
- func (observer *VideoObserver) Reset()
- type Vision
Constants ¶
const ActionableNarrationPrompt = "Describe this screen for an agent that cannot see it and must act on it.\n\n" +
"State what is on screen: the application, the visible state, any dialog, error, or confirmation, and " +
"the text of anything that asks for a decision. Quote on-screen text exactly when it carries a value, " +
"an identifier, or an amount.\n\n" +
"Then list every control a person could click, one per line, as:\n" +
" CONTROL: <label> at (<x>, <y>)\n" +
"where x and y locate the centre of the control on a 0 to 1000 scale across the image: x=0 is the " +
"left edge, x=1000 the right edge, y=0 the top, y=1000 the bottom. Use that scale and not pixels - " +
"the image you are shown may have been resized, and a fraction of the image is the same wherever it " +
"was resized to. Estimate as accurately as you can; an agent will click exactly there.\n\n" +
"Do not speculate about what is not visible. If nothing meaningful has changed, reply with exactly: no change."
ActionableNarrationPrompt is the narration a computer-use session wants.
It asks for the same persistent text as the default prompt and adds the one thing an agent cannot get any other way: where the controls are. That is not a workaround for weak models. Narration is the value precisely because it turns a screen into something that survives and can be acted on, and a description that says a Confirm button exists without saying where it is has done half the job - the agent is left inferring a coordinate from pixels, which is a different and much harder skill than reading a screen.
Positions are stated in the source's own coordinate space, which is the space computer-use actions are expressed in, so no conversion is needed anywhere.
const DefaultNarrationPrompt = "Say what this screen shows, in one sentence, for an agent that cannot see it.\n\n" +
"Say what is happening or has happened first - it is running, it finished, it failed, it is waiting for an answer - and quote the on-screen text that carries it, exactly, when it is a value, an identifier, or an amount. Nothing about layout or colour, and do not address the user. If nothing meaningful has changed, reply with exactly: no change."
DefaultNarrationPrompt is the instruction a narrator is given.
It asks for what survives. Images are pruned; the text an observer commits is what a model reads an hour later, so it has to carry the state rather than describe the picture. It also asks for silence on an unchanged screen, because a narrator that says "the same page is still open" every third of a second fills the trajectory with nothing.
It asks for the state first, and for one sentence. Both are measured. The layer that decides whether a frame is worth speaking at cannot see, so the narration is the whole of its evidence, and a description that opens with the application and the command and reaches the word "finished" in the third clause buries the only part it needs. Leading with it also costs less: against Gemini 3.5 Flash at minimal thinking, over four calls on each of two frames, this runs at about 1.1 seconds where asking for two or three sentences ran at 1.4 - and that sits on the critical path of every visual turn, because a picture is not an observation until it is text.
Variables ¶
This section is empty.
Functions ¶
func CarriesSpeech ¶
carriesSpeech reports whether a transcript contains anything a person said.
A recogniser asked about audio with no words in it has to answer somehow, and the answer is not always an empty string: SenseVoice returns ".", others return the punctuation their language model expects around nothing. The contract here is "what the user said", and text with no letter and no digit in it says nothing - in any script, which is why this asks Unicode rather than stripping a list of characters somebody noticed once. CarriesSpeech re-exports the api/v1 contract, which is where it belongs: the rule has to be the same for every adapter that reports "no words" and every consumer that reads it, or one of them turns punctuation into a turn.
Types ¶
type AudioConfig ¶
type AudioConfig struct {
// Provider is the streaming recogniser. One is created per utterance, so
// recogniser state cannot leak between turns.
Provider func() (v1.PerceptionProvider, error)
// Name defaults to "audio".
Name string
// Cadence is how often the recogniser is advanced. Zero selects 200 ms,
// which is the reference configuration.
Cadence time.Duration
// Source is the frame source this observer accepts. Empty accepts every
// audio frame, which is the ordinary single-microphone case.
Source string
}
AudioConfig configures the audio observer.
type AudioObserver ¶
type AudioObserver struct {
// contains filtered or unexported fields
}
AudioObserver recognises speech into typed revisions.
It emits provisional observations as the recogniser revises, and one final observation at the endpoint. Whether provisional observations reach the canonical trajectory is an observation policy the binding owns; this observer's job is to report what it heard, not to decide what is worth committing.
func NewAudioObserver ¶
func NewAudioObserver(config AudioConfig) (*AudioObserver, error)
NewAudioObserver creates the speech observer.
func (*AudioObserver) Accepts ¶
func (observer *AudioObserver) Accepts(frame Frame) bool
func (*AudioObserver) Cadence ¶
func (observer *AudioObserver) Cadence() time.Duration
func (*AudioObserver) Close ¶
func (observer *AudioObserver) Close() error
Close ends the utterance and reports provider-release failures to a lifecycle owner. Reset retains its historical best-effort signature for the Observer interface; graph disposers use Dispose so a reusable provider is released when the session ends and not before.
func (*AudioObserver) Dispose ¶ added in v0.2.0
func (observer *AudioObserver) Dispose() error
Dispose releases the provider for good. It is the session ending.
func (*AudioObserver) DurationMS ¶
func (observer *AudioObserver) DurationMS() uint64
DurationMS is how much audio the current utterance has consumed.
func (*AudioObserver) EagerEndOfTurn ¶ added in v0.2.0
func (observer *AudioObserver) EagerEndOfTurn() bool
EagerEndOfTurn reports that a recogniser with turn detection is moderately confident the utterance is over (Deepgram Flux's EagerEndOfTurn), before it is sure. Like SpeechEndpointed it is optional and false for every other recogniser.
func (*AudioObserver) Flush ¶
func (observer *AudioObserver) Flush(ctx context.Context) ([]Observation, error)
Flush finalises the utterance and returns the terminal observation.
func (*AudioObserver) Gate ¶
func (observer *AudioObserver) Gate(Frame) bool
Gate admits every audio frame it is handed.
The acoustic gate runs upstream, in the audio pipeline, because its decision also drives the duplex state and the endpoint - it is not only a perception decision. By the time frames reach here they have already been admitted.
func (*AudioObserver) Name ¶
func (observer *AudioObserver) Name() string
func (*AudioObserver) Observe ¶
func (observer *AudioObserver) Observe(ctx context.Context, frames []Frame) ([]Observation, error)
Observe advances the recogniser and returns any revision it produced.
func (*AudioObserver) Reset ¶
func (observer *AudioObserver) Reset()
Reset drops the utterance so the next one starts clean.
A recogniser that is one utterance is closed on the way out: an abandoned utterance - the speaker stops, a barge-in discards the turn - would otherwise strand a socket and the goroutine reading it for every utterance the session ever had. A recogniser that is one session's stream is told the utterance ended and kept, so the next first frame goes down a socket that is already open. A provider with nothing to release implements neither interface and is unaffected.
func (*AudioObserver) SpeechEndpointed ¶
func (observer *AudioObserver) SpeechEndpointed() bool
SpeechEndpointed reports an endpoint supplied by a recogniser that combines ASR with VAD. It is optional: providers without that capability continue to be endpointed by the acoustic floor exactly as before.
type ComponentSpec ¶
type ComponentSpec string
ComponentSpec names a measured observer component composition - factor F7.
It exists because the bundle is not uniformly good: at least one strong model regresses when handed the keyframe stream, through image-token dilution. Shipping a default without measuring its components per model would repeat a mistake the evidence has already identified.
const ( ComponentKeyframeNarration ComponentSpec = "keyframe+narration" ComponentNarrationOnly ComponentSpec = "narration" ComponentKeyframeOnly ComponentSpec = "keyframe" )
func ParseComponents ¶
func ParseComponents(value string) (ComponentSpec, error)
ParseComponents validates a configured level of factor F7.
type EnergyGate ¶
type EnergyGate struct {
// contains filtered or unexported fields
}
EnergyGate is a content-independent acoustic gate.
It combines an absolute energy threshold with an adaptive noise floor and applies the configured prefix and silence hysteresis. It never examines transcript text: this is the sub-millisecond, no-I/O half of the observer contract, and a gate that read words would be neither.
func NewEnergyGate ¶
func NewEnergyGate(config GateConfig, sampleRate uint32) (*EnergyGate, error)
NewEnergyGate validates the configuration and creates a gate.
func (*EnergyGate) ForceStop ¶
func (gate *EnergyGate) ForceStop() (endMS int, stopped bool)
ForceStop ends the current utterance immediately and reports where it ended, whether or not the silence hysteresis was satisfied.
It exists for turn projection: a policy that anticipates the end of a turn before silence confirms it has to be able to close the turn, and a gate that could only be closed by its own threshold would make the projection an opinion nobody could act on. It reports false when there was no utterance open, so a projection that arrives just after an ordinary endpoint is a no-op rather than a second endpoint.
func (*EnergyGate) Push ¶
func (gate *EnergyGate) Push(pcm16 []byte) (GateResult, error)
Push advances the gate over one block of PCM16 audio.
func (*EnergyGate) Reopen ¶
func (gate *EnergyGate) Reopen()
Reopen continues an utterance the gate has just closed.
It exists for the session whose client owns turn detection: the gate's silence threshold is still the right answer to "is the user audible", and the wrong answer to "has the turn ended", so the first is kept and the second is discarded. Sample accounting is untouched, so the turn's eventual end is still measured from its real beginning.
func (*EnergyGate) SilenceNS ¶
func (gate *EnergyGate) SilenceNS() uint64
SilenceNS reports how long the gate has seen silence within an utterance.
func (*EnergyGate) Speaking ¶
func (gate *EnergyGate) Speaking() bool
Speaking reports whether the gate currently believes the user is audible.
func (*EnergyGate) WrittenMS ¶
func (gate *EnergyGate) WrittenMS() int
WrittenMS is how much audio this gate has consumed.
The positions a gate reports are its own: they count from the first sample it was given. A caller that builds a second gate part-way through a session - because the sample rate changed, or because it keeps one gate per utterance - owns the difference between those positions and the session's, and cannot compute it without this.
type Factory ¶
Factory creates one observer for one session.
Observers hold per-session state - what the screen looked like a moment ago, which recogniser is mid-utterance - so they cannot be shared between sessions. The declared name and kind let a binding report what it supports without constructing anything, which is what negotiation needs before a session exists.
func VideoFactory ¶
func VideoFactory(config VideoConfig) Factory
VideoFactory builds a per-session video observer from one configuration.
type Frame ¶
type Frame struct {
Kind FrameKind `json:"kind"`
// Source names the stream: "microphone", "screen", "camera", or an opaque
// client-declared identifier. Screen and camera are simultaneously live and
// semantically different - you act on the screen, you observe the camera -
// so this is never optional.
Source string `json:"source"`
// CapturedNS is source time, which may precede commit time.
CapturedNS uint64 `json:"captured_ns"`
// Index counts frames within a source.
Index uint64 `json:"index,omitempty"`
// PCM16LE and SampleRateHz carry audio.
PCM16LE []byte `json:"-"`
SampleRateHz uint32 `json:"sample_rate_hz,omitempty"`
// SampleOffset is the absolute position of this audio in its source.
SampleOffset uint64 `json:"sample_offset,omitempty"`
// Image, MIMEType, Width, and Height carry a still image.
Image []byte `json:"-"`
MIMEType string `json:"mime_type,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
}
Frame is one unit of raw input.
Audio and image share one type deliberately. The Observer contract is the same for both, and two frame types would make it two contracts that happened to be spelled alike.
type GateConfig ¶
type GateConfig struct {
// Threshold is the Realtime-compatible sensitivity in [0,1].
Threshold float64
// PrefixPaddingMS is how much audio before the onset is kept, so the first
// syllable is not clipped off the front of an utterance.
PrefixPaddingMS int
// SilenceDurationMS is how much silence ends an utterance.
SilenceDurationMS int
// SpeechDurationMS is how much voiced audio must accumulate before an
// utterance starts. Zero selects 120 ms.
//
// The gate had hysteresis on one side only: half a second of silence to
// believe a turn ended, and a single block above the threshold to believe
// one began. A door slam, a keyboard, a lip smack all clear an energy
// threshold, so anything percussive opened an utterance - and a recogniser
// asked what was in it answers honestly that there were no words, which is
// then indistinguishable from the user having spoken.
//
// It costs nothing to wait, because the prefix buffer is already keeping
// this audio: what the threshold delays is the decision, not the sound. A
// syllable is comfortably longer than any transient, so the smallest thing
// a person can say still opens a turn with its onset intact.
SpeechDurationMS int
}
GateConfig configures the acoustic gate.
func DefaultGateConfig ¶
func DefaultGateConfig() GateConfig
DefaultGateConfig matches the Realtime server-VAD defaults.
type GateResult ¶
type GateResult struct {
Started bool
Stopped bool
Audio []byte
AudioStartMS int
AudioEndMS int
SilenceNS uint64
}
GateResult is what the acoustic gate decided about a block of audio.
type ModelNarrator ¶
type ModelNarrator struct {
// contains filtered or unexported fields
}
ModelNarrator narrates with a vision model.
The narrator is a composition slot, not a fixed component. The primary configuration is the session's own model narrating as a side-output, which is what the measured result used and what avoids putting a second model in the loop. But that presumes the foreground model can see, and a full-duplex binding breaks the presumption outright - so a dedicated vision-language model is a supported alternative rather than a fallback nobody planned for. Which one is in use is a session-level composition and a measurable factor.
func NewDedicatedNarrator ¶
func NewDedicatedNarrator(vision Vision) (*ModelNarrator, error)
NewDedicatedNarrator narrates with a separate vision-language model.
func NewNarrator ¶
func NewNarrator(config NarratorConfig) (*ModelNarrator, error)
NewNarrator creates a narrator.
func NewSessionNarrator ¶
func NewSessionNarrator(vision Vision) (*ModelNarrator, error)
NewSessionNarrator narrates with the session's own model.
func (*ModelNarrator) Metrics ¶
func (narrator *ModelNarrator) Metrics() NarratorMetrics
func (*ModelNarrator) Name ¶
func (narrator *ModelNarrator) Name() string
Name reports the composition and the model behind it.
func (*ModelNarrator) Narrate ¶
func (narrator *ModelNarrator) Narrate( ctx context.Context, frames []Frame, _ trajectory.Snapshot, ) (string, error)
Narrate describes the frames.
type Narrator ¶
type Narrator interface {
Name() string
Narrate(context.Context, []Frame, trajectory.Snapshot) (string, error)
}
Narrator turns admitted frames into the persistent text that survives after the images themselves are pruned.
It is a composition slot rather than a fixed component. The primary configuration is the session's own model narrating as a side-output, which is what the measured result used and what avoids a second model in the loop. But that presumes the foreground model can see, and a full-duplex binding breaks the presumption outright, so a dedicated vision-language model is a supported alternative rather than a fallback nobody planned for.
type NarratorConfig ¶
type NarratorConfig struct {
Vision Vision
// Prompt overrides the shipped narration instruction.
Prompt string
// Label distinguishes a session narrator from a dedicated one in reports.
// It records the composition, not the model.
Label string
// Governor admits narration against the same compute budget as everything
// else. Video narration is a new class competing for the same GPU as the
// recogniser, the fast model, and the synthesiser, so it belongs under the
// same governor rather than beside it - a narrator with its own private
// budget is a narrator that can starve the voice.
//
// Nil means unadmitted, which is correct for a deployment whose vision
// model is hosted elsewhere and therefore competes for nothing local.
Governor *admission.Governor
// Class defaults to background: a screen description is worth having and
// never worth delaying a spoken turn for.
Class admission.Class
// Deadline bounds how long a narration may wait for capacity. Zero selects
// two seconds; a description of a screen that has since changed is not
// worth the tokens.
Deadline time.Duration
}
NarratorConfig configures a model narrator.
type NarratorMetrics ¶
type NarratorMetrics struct {
Narrations uint64 `json:"narrations"`
Suppressed uint64 `json:"suppressed"`
// Unadmitted counts narrations the governor refused. A number that climbs
// says the deployment is trying to see more than its GPU can describe.
Unadmitted uint64 `json:"unadmitted"`
}
NarratorMetrics reports how often the narrator declined, which is part of what makes an idle source cheap.
type Observation ¶
type Observation struct {
Text string `json:"text"`
Observer string `json:"observer"`
Source string `json:"source,omitempty"`
Authority trajectory.Authority `json:"authority"`
// Media are handles to attachments retained outside the trajectory.
Media []trajectory.MediaRef `json:"media,omitempty"`
// Described marks text that says what the media shows rather than what the
// person said. A picture a client attaches carries user authority, because
// somebody putting a screenshot in front of an agent is somebody talking -
// but the sentence describing it was written by a narrator, and anything
// reading it for what the person asked for is reading the wrong author.
Described bool `json:"described,omitempty"`
// Revision numbers successive views of the same continuous input.
Revision uint64 `json:"revision,omitempty"`
// Supersedes names an earlier revision this observation replaces.
Supersedes uint64 `json:"supersedes,omitempty"`
// StableText is the prefix the observer will not revise. It is what an
// observation policy that admits partials is allowed to admit.
StableText string `json:"stable_text,omitempty"`
// Provisional marks an observation that later evidence may replace. The
// binding's observation policy decides whether provisional observations
// reach the canonical trajectory at all.
Provisional bool `json:"provisional,omitempty"`
// Final marks the terminal observation for a unit of input - the end of an
// utterance, the close of a video source.
Final bool `json:"final,omitempty"`
OccurredNS uint64 `json:"occurred_ns,omitempty"`
}
Observation is persistent text committed to the trajectory, plus the provenance that decides what it is allowed to do.
Authority is the injection defence. Text an observer read off a screen carries observer authority forever: it can be reasoned about and it can never become an instruction. Only the audio observer, reporting the human participant's own speech, produces user authority.
func (Observation) InspectionCause ¶
func (Observation) InspectionCause() element.InspectionCauseKind
InspectionCause identifies an emitted perception revision without exposing its text, media, observer, source, or authority.
func (Observation) Meta ¶
func (observation Observation) Meta() *trajectory.ObservationMeta
Meta renders the trajectory observation provenance, or nil for plain user speech, which is the pre-existing shape of the audio path.
func (Observation) Producer ¶
func (observation Observation) Producer() trajectory.Producer
Producer renders the trajectory producer for this observation. Provenance is derived from authority rather than supplied alongside it, so the two cannot disagree.
func (Observation) Validate ¶
func (observation Observation) Validate() error
Validate rejects an observation that could not be committed.
type Observer ¶
type Observer interface {
Name() string
// Accepts reports whether this observer handles a source at all, so a
// session with several sources does not hand every frame to every
// observer.
Accepts(Frame) bool
// Gate reports whether a frame carries anything worth extracting. It must
// be cheap and must not block.
Gate(Frame) bool
// Observe extracts persistent text from admitted frames. It may return no
// observations, which is the normal outcome for input that changed too
// little to be worth saying anything about.
Observe(context.Context, []Frame) ([]Observation, error)
// Flush completes any in-flight observation at a boundary - an endpoint, a
// source closing, a session ending. It is not in the minimal contract
// because it is not conceptually necessary; it is here because a streaming
// recogniser genuinely has an in-flight state that must be finished rather
// than dropped.
Flush(context.Context) ([]Observation, error)
// Cadence is how often Observe should be called while frames are being
// admitted. Zero means call it as frames arrive.
Cadence() time.Duration
// Reset discards per-unit state, so one utterance's recogniser state
// cannot leak into the next.
Reset()
}
Observer converts one continuous stream into observations.
Gate must be sub-millisecond and must not perform I/O. It is what makes an idle stream nearly free: roughly six steps in ten are fully idle in the measured video case, and a gate that cost anything real would spend most of its budget on nothing happening.
type ObserverSetSpec ¶
type ObserverSetSpec string
ObserverSetSpec names a measured observer composition, so a report can state the level rather than a list of constructor arguments.
const ( // SetAudioOnly is the reference: voice and nothing else. SetAudioOnly ObserverSetSpec = "audio" // SetAudioVideo adds the video observer. SetAudioVideo ObserverSetSpec = "audio+video" // SetVideoOnly removes the audio observer, for tasks with no speech. SetVideoOnly ObserverSetSpec = "video" )
func ParseObserverSet ¶
func ParseObserverSet(value string) (ObserverSetSpec, error)
ParseObserverSet validates a configured level of factor F3.
type RefreshableObserver ¶
type RefreshableObserver interface {
RefreshNext()
}
RefreshableObserver can be asked to admit its next frame even when ordinary change detection would collapse it. Successful embodied actions use this boundary: the next observation is the feedback for one action chunk, and an unchanged screen is itself meaningful evidence that the effect did not produce a new visual state. Only one frame is forced; adaptive observation resumes immediately afterward.
type Retainer ¶
type Retainer interface {
Retain(trajectory.MediaRef, []byte) (trajectory.MediaRef, error)
}
Retainer stores frame bytes outside the trajectory and returns the handle that names them. It is the session's media store; the observer takes it as an interface so a test can retain nothing.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is the observer composition for one session.
Observers are independently switchable, which is what makes the observer set a measured factor rather than an assumed bundle.
func NewSet ¶
NewSet composes observers, rejecting duplicate names so a report can name exactly which observer produced what.
type SourceRefreshableObserver ¶
type SourceRefreshableObserver interface {
RefreshSource(source string)
}
SourceRefreshableObserver is the unambiguous refresh boundary for observers that accept more than one visual source. A screen effect must force a screen observation, not whichever camera or screen frame happens to arrive first. RefreshableObserver remains supported for single-source observers and older bindings.
type StaticNarrator ¶
type StaticNarrator struct {
Text string
}
StaticNarrator returns fixed text. It exists for tests and for the keyframe-only measurement level, where the question is what images are worth without narration.
func (StaticNarrator) Name ¶
func (narrator StaticNarrator) Name() string
func (StaticNarrator) Narrate ¶
func (narrator StaticNarrator) Narrate(context.Context, []Frame, trajectory.Snapshot) (string, error)
type VideoConfig ¶
type VideoConfig struct {
// Name defaults to "video".
Name string
// Sources restricts the observer to named sources. Empty accepts every
// image frame, which is the ordinary single-screen case.
Sources []string
// Cadence is the minimum interval between extractions. Zero selects 333 ms,
// roughly three frames a second, which is the rate the measured result
// used and enough for a screen a person is working on.
Cadence time.Duration
// ExternalCadence disables the observer's wall-clock sampling gate. It is
// used when admission timing is already an explicit upstream graph element:
// every delivered trigger is then considered immediately, while byte and
// pixel change detection remain local to the observer. Keeping this opt-in
// preserves the legacy/session API's measured 333 ms default without
// hiding a second timing policy inside graph-native compositions.
ExternalCadence bool
// ChangeThreshold is the fraction of the downscaled image that must differ
// before a frame is worth narrating, in [0,1]. Zero selects 0.02.
ChangeThreshold float64
// Narrator turns admitted frames into persistent text. Without one the
// observer is inert: keyframes with no narration are the configuration the
// evidence found weakest, so it is not something to fall into by omission.
Narrator Narrator
// Retainer stores admitted frames so an observation can reference them.
// Without one, observations carry text and no media, which is the
// narration-only configuration.
Retainer Retainer
// AttachKeyframes controls whether admitted frames are retained and
// referenced. It is a measured factor rather than an assumption: at least
// one strong model regresses when handed a keyframe stream, through
// image-token dilution.
AttachKeyframes bool
// Now is the monotonic clock the sampling interval is measured against.
// Zero selects the system clock.
//
// It is deliberately not the frame's own capture time. A capture time is
// whatever the client chose to write in the event, and the sampling
// interval is a bound on what this server will spend: a client that sends
// no timestamps would otherwise disable the cadence entirely, and one that
// sends the same timestamp on every frame would disable the observer. The
// gate answers "how often am I willing to decode", which is a question
// about this process rather than about the sender.
Now func() uint64
}
VideoConfig configures the video observer.
type VideoMetrics ¶
type VideoMetrics struct {
Frames uint64 `json:"frames"`
Admitted uint64 `json:"admitted"`
Narrations uint64 `json:"narrations"`
}
VideoMetrics is what the efficiency gates measure.
type VideoObserver ¶
type VideoObserver struct {
// contains filtered or unexported fields
}
VideoObserver watches a video source and commits what changed.
The gate is in two stages, and the split is honest about what "costs almost nothing" can actually mean. Gate itself does no decoding: it rejects a frame that is byte-identical to the last admitted one and enforces the sampling interval, which is the case that matters because a static screen is most of the time - the measured decomposition found roughly six steps in ten fully idle. Only a frame that survives that is decoded and compared pixel by pixel, inside Observe, where I/O is expected.
func NewVideoObserver ¶
func NewVideoObserver(config VideoConfig) (*VideoObserver, error)
NewVideoObserver creates the observer.
func (*VideoObserver) Accepts ¶
func (observer *VideoObserver) Accepts(frame Frame) bool
func (*VideoObserver) Cadence ¶
func (observer *VideoObserver) Cadence() time.Duration
func (*VideoObserver) Flush ¶
func (observer *VideoObserver) Flush(context.Context) ([]Observation, error)
Flush has nothing to complete: a video observer commits each admitted frame as it goes, and there is no in-flight state to finish.
func (*VideoObserver) Gate ¶
func (observer *VideoObserver) Gate(frame Frame) bool
Gate is the cheap half: no decoding, no I/O, no allocation beyond a compare.
func (*VideoObserver) Metrics ¶
func (observer *VideoObserver) Metrics() VideoMetrics
Metrics reports how much of the stream the gate discarded, which is the number the efficiency gate for an idle source is stated against.
func (*VideoObserver) Name ¶
func (observer *VideoObserver) Name() string
func (*VideoObserver) Observe ¶
func (observer *VideoObserver) Observe(ctx context.Context, frames []Frame) ([]Observation, error)
Observe decodes what the gate admitted, checks whether it actually changed, and narrates it if it did.
func (*VideoObserver) RefreshNext ¶
func (observer *VideoObserver) RefreshNext()
RefreshNext forces exactly one post-effect keyframe through the adaptive gate. It does not discard the prior signature: the forced frame becomes the new comparison baseline and normal collapse resumes on the frame after it.
func (*VideoObserver) RefreshSource ¶
func (observer *VideoObserver) RefreshSource(source string)
RefreshSource forces exactly one post-effect keyframe from source without allowing a frame from another simultaneously active source to consume the boundary. Realtime computer-use consequences target the screen even while a camera stream is active, so this is the precise form of RefreshNext for a multi-source observer.
func (*VideoObserver) Reset ¶
func (observer *VideoObserver) Reset()
Reset forgets what every source looked like, so each source's next frame is treated as new. A session boundary must not inherit a previous session's screen, camera, cadence, or pending refresh state.
type Vision ¶
type Vision interface {
Name() string
Describe(ctx context.Context, images []Image, prompt string) (string, error)
}
Vision describes images.
It is deliberately narrower than continuation.Provider. A narrator does not continue the trajectory, does not stream, and cannot emit a tool call, and giving it the provider interface would make all three possible by accident - the same reasoning that keeps policy models on their own contract.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package noisefilter implements the bounded, pre-ASR PCM filtering contract.
|
Package noisefilter implements the bounded, pre-ASR PCM filtering contract. |
|
Package voices tells the person the agent is talking to from another voice in the room.
|
Package voices tells the person the agent is talking to from another voice in the room. |