Documentation
¶
Overview ¶
Package webui builds the browser half of agentscope on first run.
The wasm UI is not committed (it is 25 MB, 5.5 MB gzipped, and would be in every clone for ever). `agentscope serve` finds the UI SOURCES that belong to its own binary, compiles them with the local Go toolchain for GOOS=js GOARCH=wasm into the user's cache directory, and serves that.
- Where the sources are. After `go install github.com/go-agentsync/agentscope/cmd/agentscope@vX` they are in the module cache at the version the binary was built from (runtime/debug.ReadBuildInfo gives the version, `go env GOMODCACHE` the place). Inside a checkout (a development binary has no version) they are the working tree, found upward from the working directory or from the binary.
- Where the build goes. <user cache>/agentscope/<key>, where the key is the version (or, for a checkout, a digest of the sources) and the toolchain's `go version`: a new Go release or a changed source is a new entry, never an overwrite.
- How it is written. Into a temporary directory beside the entry, then renamed into place, so a reader never sees half a build and two first runs racing each other cannot corrupt it: whichever rename wins is the entry, the other build is thrown away and its caller uses the winner's.
- What it will not build from. A source directory (and every parent up to the module cache) that is not owned by the current user or root, or that is writable by its group or by everyone: a stranger who can write there decides what the compiler runs. Commands are exec'd with an argument list, never through a shell.
`agentscope serve --web DIR` skips all of it.
Index ¶
Constants ¶
const ModulePath = "github.com/go-agentsync/agentscope"
ModulePath is the module the UI sources belong to.
Variables ¶
var ErrNoGo = errors.New("agentscope builds its UI on first run and needs the Go toolchain on PATH, which was not found: install Go, or serve a UI you built elsewhere with `agentscope serve --web DIR`")
ErrNoGo is returned when no go binary can be found.
Functions ¶
Types ¶
type Options ¶
type Options struct {
// Version is the module version of the running binary; "" reads it from
// the binary's build info. "(devel)" or "" means a checkout.
Version string
// CacheDir is where builds go; "" is <user cache dir>/agentscope.
CacheDir string
// Go is the go binary; "" looks it up on PATH.
Go string
// Cwd and ExecDir are where a checkout is looked for; "" reads them.
Cwd, ExecDir string
// Out receives progress lines; nil discards them.
Out io.Writer
}
Options configures Ensure. The zero value is the production behaviour.