demo

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: BSD-3-Clause Imports: 22 Imported by: 1 module, 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 demo renders the agentscope screen from a SYNTHETIC, deterministic scenario into one animated SVG, for demo videos and documentation.

The scenario drives the SAME view-model as the live screen (ui.ViewModel): a step applies a snapshot, switches a tab, picks a theme or a language, exactly as the browser or the server would. Nothing is drawn by hand and nothing is read from this machine: every account, plan, session and repository below is invented, and the clock is a constant, so the same scenario yields the same bytes on every run.

Index

Constants

View Source
const (
	MinSize = 320
	MaxSize = 4096
)

Size bounds: a capture is a picture of a window, not an allocation attack.

View Source
const (
	// WebMFPS is the nominal frame rate. Timestamps come from the scenario's own
	// holds; this only sizes the last frame's duration.
	WebMFPS = 25
	// WebMCPUUsed is the encoder speed preset.
	WebMCPUUsed = 4
	// DefaultQuality is the VP8 quantizer index held: 1 (best) to 63 (worst).
	DefaultQuality = 10
	// MinQuality and MaxQuality bound the --quality flag: avkit's vp8enc takes
	// 1 to 63 (the bitstream's own quantizer index is 7 bits, RFC 6386 section 9.6).
	MinQuality, MaxQuality = 1, 63
)

The WebM encoder settings. CPUUsed 4 is avkit's slow, sharp preset (the default 5 costs about 5 dB), right for UI text; the frames are few and the encode is bounded by Quality, a constant quantizer, so the file size follows the content.

View Source
const (
	FormatSVG  = "svg"
	FormatWebM = "webm"
)

Format names.

View Source
const DefaultSize = "1280x720"

DefaultSize is the captured window, in logical pixels.

Variables

View Source
var Epoch = time.Date(2030, 1, 15, 10, 0, 0, 0, time.UTC)

Epoch is the demo's fixed "now". Nothing in the output reads the real clock.

Functions

func CheckQuality added in v0.15.1

func CheckQuality(quality int) error

CheckQuality refuses a quality outside 1 to 63 (0 is the default). Any size is taken: avkit's vp8enc pads the planes to whole macroblocks itself (v0.20.2).

func DefaultOutDir

func DefaultOutDir() (string, error)

DefaultOutDir is the durable directory captures go to: under the user's config directory, never inside a repository.

func InsideGitTree

func InsideGitTree(p string) (bool, error)

InsideGitTree reports whether p, or a directory above it, holds a .git.

func Names

func Names() []string

Names are the scenarios, sorted.

func ParseSize

func ParseSize(s string) (w, h int, err error)

ParseSize reads "WIDTHxHEIGHT" within [MinSize, MaxSize].

func ResolveFormat added in v0.15.0

func ResolveFormat(format, out string) (string, error)

ResolveFormat settles the output format from --format and the --out path. An empty format is inferred from the extension (.svg or .webm) and is svg when the path has neither; a named format must not contradict a known extension.

func Snapshot

func Snapshot(labColor, personalColor string) model.Snapshot

Snapshot is the invented picture of the agent network at Epoch: five sessions in two organisations, their sub-agents, leases and one tell.

func Usage

func Usage(labColor, personalColor string) *model.Usage

Usage is the Quota tab's data: two invented accounts. A non-empty colour is the one the owner gave that account.

Types

type Env

type Env struct {
	Scene *ui.Scene
	VM    *ui.ViewModel
}

Env is what a step may touch: the screen and its view-model, the only door the live UI has too.

type Options

type Options struct {
	W, H int
}

Options tune Render. The zero value renders DefaultSize.

type Result

type Result struct {
	SVG      []byte
	Frames   int           // frames recorded, one per step
	Duration time.Duration // the loop length
	Stats    svg.Stats     // the assembly: slots, pictures, shared subtrees, sizes
	Raster   int           // elements that embed a PNG; 0 means fully vector
	Doc      *svg.Document // the assembly, whose Frame(i) is the still of slot i
	Texts    []string      // every distinct string drawn: the outlines hide them from a text scan
}

Result is one rendered scenario.

func Render

func Render(name string, o Options) (*Result, error)

Render plays the scenario against a fresh Scene and view-model and assembles the recorded frames into one animated SVG. It is deterministic: no clock, no file and no network is read.

func Write

func Write(name, out string, o Options) (*Result, error)

Write renders the scenario and writes it to out, refusing a path inside a git work tree. The directory is created when missing.

type Scenario

type Scenario struct {
	Name, Title string
	Steps       func() []Step
}

Scenario is a named, ordered list of steps.

func Lookup

func Lookup(name string) (Scenario, error)

Lookup returns the scenario called name, or an error naming the valid ones.

type Step

type Step struct {
	Hold time.Duration
	Do   func(*Env)
}

Step is one beat of a scenario: Do changes the view-model, then the screen is recorded and held for Hold.

type WebM added in v0.15.0

type WebM struct {
	*Result
	Bytes   []byte
	Quality int
}

WebM is one rendered scenario as a video.

func RenderWebM added in v0.15.0

func RenderWebM(name string, o Options, quality int) (*WebM, error)

RenderWebM plays the scenario exactly as Render does and encodes the frames it recorded, rasterised, as a VP8 WebM. quality 0 means DefaultQuality.

func WriteWebM added in v0.15.0

func WriteWebM(name, out string, o Options, quality int) (*WebM, error)

WriteWebM renders the scenario to out, refusing a path inside a git work tree.

Jump to

Keyboard shortcuts

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