testserver

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2026 License: Apache-2.0 Imports: 31 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testserver assembles a complete OpenRealtime server for tests that need a real one.

It is the real gateway, the real cascade binding, and the real WebRTC adapter, with scripted providers standing in for the models. That combination is what several kinds of test need and none of them should reimplement: a browser cannot be pointed at a mock, and a client that only ever met a mock proves nothing about the server.

Scripted rather than stubbed to nothing: the fast provider speaks, the slow provider calls a tool, and the synthesiser produces real audio, because a client's job is to handle all three and a test that skipped any of them would pass on a client that could not.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Transcript is what the recogniser reports for any speech it is given.
	Transcript string
	// ToolName and ToolArguments are the call the slow provider issues. An
	// empty name means the slow provider only speaks.
	ToolName      string
	ToolArguments string
	// ToolCalls is a sequence of calls, one per slow turn, for a client whose
	// point is that it runs several different kinds of tool. A test that needs
	// one call uses ToolName; a test that needs to see a file read, a browser
	// clicked, and an artifact rendered needs them to arrive separately,
	// because a client that batched them would be a client the protocol does
	// not describe.
	ToolCalls []ScriptedCall
	// Narration is what the video observer reports for any frame.
	Narration string
	// FastSpendsBudgetThinking makes the fast provider return no assistant
	// text, having written its deliberation into the content field and hit
	// the output limit. It is what a thinking model on a short budget does,
	// and it is the case a turn has to report rather than fall silent on.
	FastSpendsBudgetThinking bool
	// AllowedOrigins are the web origins the WebRTC adapter will answer.
	AllowedOrigins []string
	// GraphInspection mounts the real compatibility graph adapter so a client
	// can negotiate and consume the canonical management API. Tests that only
	// need protocol behavior leave it off and retain the smallest stack.
	GraphInspection bool
	// TraceRecording opts the mounted compatibility graph into the bounded,
	// payload-free recorder. It is separate from live inspection so tests can
	// measure and assert the zero-recorder profile explicitly.
	TraceRecording bool
	// ClientEffectIssuer enables negotiated server-issued host effect receipts.
	// It is deliberately an interface seam so integration fixtures exercise
	// the same issuer selected by a real deployment.
	ClientEffectIssuer effectauthority.EffectReceiptIssuerProvider
	// ManagementAuthorizer explicitly enables the static-catalog and authoring
	// management profile on the same server as realtime. Session inspection
	// keeps its independently negotiated gateway capability. Tests issue their
	// own operator grants through this seam; no token is built into the server.
	ManagementAuthorizer management.Authorizer
	// SourceReading optionally adds the separately authorized, rooted authoring
	// lookup boundary. It never follows from ManagementAuthorizer alone.
	SourceReading management.SourceReading
	// SourcePublication optionally adds the separately authorized authoring
	// mutation boundary. It never follows from ManagementAuthorizer alone.
	SourcePublication management.SourcePublication
}

Config describes the conversation the scripted providers will hold.

type ScriptedCall

type ScriptedCall struct {
	Name      string
	Arguments string
}

ScriptedCall is one tool call the slow provider issues, on its own turn.

type Stack

type Stack struct {
	// ProtocolURL is the WebSocket endpoint, ws://host:port/v1/realtime.
	ProtocolURL string
	// AdapterURL is where a WebRTC client POSTs an SDP offer.
	AdapterURL string
	// Static management identities are non-secret evidence used by clients to
	// request and rebind the exact graph, values schema, and descriptor.
	Graph           ir.Graph
	ValuesSchema    graphschema.Bundle
	ElementIdentity element.Identity
	AuthoringSource string
}

Stack is a running server and its adapter.

func Start

func Start(t testing.TB, config Config) Stack

Start brings up a server and registers its shutdown with the test.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL