script

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 14 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 script runs one walk-through three ways (docs/scripts.md):

  • guide: on the owner's desk as an ADE guide, moved on by the owner (onboarding);
  • demo: on its own, step after step, pointing as it goes, for a recording;
  • test: without a page, checking what each step expects, and putting the desk back.

A script is a guide with two additions per step: do (look-only tool calls that drive the desk, as a reflex may) and expect (what the desk should show after). Because every desk action is a tool here, the same script drives the app in all three modes; a recorder only has to watch.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HoldFor

func HoldFor(st Step) time.Duration

HoldFor is how long a demo shows a step: what it asks, or long enough to read what it says.

Types

type Call

type Call struct {
	Tool  string          `json:"tool"`
	Input json.RawMessage `json:"input,omitempty"`
}

Call is one tool call a step makes.

type Expect

type Expect struct {
	Focused string   `json:"focused,omitempty"` // the view in front
	Open    []string `json:"open,omitempty"`    // views with a window open
	Closed  []string `json:"closed,omitempty"`  // views with none
	Mode    string   `json:"mode,omitempty"`
	Layout  string   `json:"layout,omitempty"`
	// Tool calls a look-only tool; its answer, as text, must contain Contains.
	Tool     *Call  `json:"tool,omitempty"`
	Contains string `json:"contains,omitempty"`
}

Expect is what the desk should show after a step. Every field set must hold.

type Report

type Report struct {
	Script string       `json:"script"`
	Mode   string       `json:"mode"`
	Status string       `json:"status"` // running | passed | failed | done | stopped
	Steps  []StepResult `json:"steps,omitempty"`
}

Report is how a run went.

type Script

type Script struct {
	Name    string `json:"name"`
	About   string `json:"about,omitempty"`
	Steps   []Step `json:"steps"`
	Updated string `json:"updated,omitempty"`
}

Script is a named walk-through.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service keeps scripts and runs them.

func New

func New(ctx context.Context, k kernel.Kernel) (*Service, error)

New opens the store.

func (*Service) Close

func (s *Service) Close(context.Context) error

Close stops a running demo and stops following the guide.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, name string) error

Delete removes a script.

func (*Service) Demo

func (s *Service) Demo(ctx context.Context, name string) (Script, error)

Demo runs a script on its own, step after step, in the background: each step's calls, then what it points at and says, held long enough to read. It announces each step (script.step) so a recorder can follow, and script.done at the end.

func (*Service) Get

func (s *Service) Get(ctx context.Context, name string) (Script, error)

Get reads a script.

func (*Service) Guide

func (s *Service) Guide(ctx context.Context, name string) (any, error)

Guide puts a script on the owner's desk as an ADE guide: the owner moves it on, and each step's calls run as it comes up. The first step's calls run before the guide starts, so what it points at is there.

func (*Service) List

func (s *Service) List(ctx context.Context) ([]Script, error)

List lists the scripts.

func (*Service) Mount

func (s *Service) Mount(mux *http.ServeMux)

Mount serves the scripts for the page and for a recorder:

GET  /api/scripts             every script
GET  /api/scripts/{name}      one
POST /api/scripts/{name}/run  {mode}: guide | demo | test
POST /api/scripts/stop        stop the demo

func (*Service) Run

func (s *Service) Run(ctx context.Context, name, mode string) (any, error)

Run runs a script in a mode.

func (*Service) Save

func (s *Service) Save(ctx context.Context, sc Script) error

Save keeps a script, replacing one of the same name.

func (*Service) Stop

func (s *Service) Stop() bool

Stop stops a running demo.

func (*Service) Test

func (s *Service) Test(ctx context.Context, name string) (Report, error)

Test runs a script without a page: each step's calls, then its checks. The desk is put back as it was afterwards, so a test can run on the owner's own desk.

func (*Service) Tools

func (s *Service) Tools() []kernel.BoundTool

Tools are the scripts' tools, for every agent.

type Step

type Step struct {
	Say    string            `json:"say"`
	Point  []json.RawMessage `json:"point,omitempty"` // ADE targets: {window|view, anchor?, label?}
	Style  string            `json:"style,omitempty"` // highlight or spotlight
	Await  json.RawMessage   `json:"await,omitempty"` // as an ADE guide step: {kind: ack|open|focus, view}
	Hint   string            `json:"hint,omitempty"`
	Do     []Call            `json:"do,omitempty"`
	Expect *Expect           `json:"expect,omitempty"`
	// HoldMS is how long a demo shows the step; 0 is worked out from what it says.
	HoldMS int `json:"hold_ms,omitempty"`
	// Zoom asks a recorder or the page to move the camera in on what the step points at.
	Zoom bool `json:"zoom,omitempty"`
}

Step is one step: what the owner is told, what is pointed at, what the step does first and what should hold after it.

type StepResult

type StepResult struct {
	Index  int      `json:"index"`
	Say    string   `json:"say"`
	OK     bool     `json:"ok"`
	Failed []string `json:"failed,omitempty"`
}

StepResult is how one step of a test went.

Jump to

Keyboard shortcuts

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