build

package
v0.7.37 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 35 Imported by: 0

Documentation

Overview

Package build writes a Writing Voice with the Voice Writer: it stages the person's writing samples, decodes them before any agent sees them (pkg/runner/decode, the Knowledge Creator's decode step), runs the built-in Voice Writer over their text with the current voice when there is one (pkg/runner/localrun), and returns the VOICE.md it wrote, held to the format. It keeps nothing: the CLI keeps the result in this computer's store, and a hosted build's driver writes it out.

On this computer the Voice Writer runs against the model the runner policy names, for no credits, and nothing it reads or writes is reviewed. A voice reaches the account only by the person's choice, and is reviewed there.

Index

Constants

View Source
const MaxBriefBytes = 4 << 10

MaxBriefBytes caps a brief or a note.

View Source
const MaxSampleBytes = 10 << 20

MaxSampleBytes caps the samples as given, before they are decoded: a hosted build's inputs are capped the same (10 MB).

View Source
const MaxURLs = 20

MaxURLs bounds the addresses one build takes.

Variables

View Source
var ErrNoReviewKey = errors.New("a sample from a web address is read by AI Review first, which takes your own TypeSafe key, and none was found; give the samples as files, or set the key")

ErrNoReviewKey refuses addresses with nothing to review them: the person's own TypeSafe key on this computer, the job's credential on a sandbox host: AI Review reads every page before the Voice Writer does.

Functions

func PageLines added in v0.7.23

func PageLines(pages []*Page, files []runnerdecode.File, reader string) map[string]string

PageLines are the receipt's lines for the pages a build read for reader, the built-in that reads them, keyed source.<url-n>.

func ParseURLs

func ParseURLs(urls []string) ([]*sources.Source, error)

ParseURLs reads the addresses a build was given as url sources, each with the id url-<n>.

Types

type Job

type Job string

Job is which of the Voice Writer's three jobs a build is.

const (
	// Create writes the first voice from samples and a brief.
	Create Job = "create"
	// Improve writes the voice again from the current one, more samples
	// and a brief.
	Improve Job = "improve"
	// Edit writes the voice again from the current one and a note, with
	// more samples when the person gives some.
	Edit Job = "edit"
)

func (Job) Source

func (j Job) Source() voice.Source

Source is the voice source a job's result records.

type Options

type Options struct {
	Job Job
	// Samples are the files and directories of the person's writing:
	// required for Create and Improve, optional for Edit.
	Samples []string
	// Brief is how the person wants to sound (Create, Improve), or the
	// change to make (Edit, where it is required).
	Brief string
	// Current is the voice as it stands: required for Improve and Edit,
	// refused for Create.
	Current []byte
	// URLs are web addresses of the person's writing (ParseURLs), fetched
	// before the run and read by AI Review first: they take Review and
	// Web, and are refused on a sandbox host.
	URLs []*sources.Source
	// Review is AI Review (the person's own key on this computer, the
	// registry's route with the job's credential on a sandbox host), which
	// reads every
	// fetched page's text before the run.
	Review webscan.Scanner
	// Web is the web tools' configuration with the same scanner, for a
	// page whose text is drawn by scripts: the Voice Writer reads it with
	// web_read, held to the addresses given (the build sets Given).
	Web *engine.WebRun
	// MaxTextBytes, when set, caps the samples' decoded text the Voice
	// Writer is given (a hosted build's 1 MB): past it a sample is cut
	// short or left out, and the task says which.
	MaxTextBytes int64

	Home       string
	Policy     *policy.Policy
	PolicySHA  string
	PolicyFile *policy.File
	// Build is the client's build identity, for the receipt.
	Build string
	// OutDir receives the run's reports and receipts.
	OutDir  string
	Budgets *spec.Budgets
	RunID   string
	Stderr  io.Writer
	OnUsage func(receipt.Usage)
	// Hosted is a sandbox host's build, which never spends a model sign-in
	// (localrun.Run.Hosted). Its pages are read by AI Review through the
	// registry with the job's credential (Review and Web say so).
	Hosted bool
	// Credits is the credits-session client for a policy that pays with
	// Agentry credits (model provider agentry); see localrun.Run.Credits.
	Credits *inference.Client
	// Render lets a hosted build render a page drawn by scripts: its host
	// dispatched it as a browser job. A build on this computer renders
	// without it.
	Render bool
}

Options configure one build.

type Page

type Page struct {
	// URL is the address as shown (a query hidden).
	URL string `json:"url"`
	// Sample is the sample it was staged as, when its text was read before
	// the run; empty for a page read with web_read, or withheld.
	Sample string `json:"sample,omitempty"`
	// Rendered says the page's text is drawn by scripts, so the Voice
	// Writer reads it with web_read, rendered, AI Review reading it there.
	Rendered bool `json:"rendered,omitempty"`
	// Withheld says why AI Review did not pass its text, or why it could
	// not be read; the Voice Writer never saw it.
	Withheld string `json:"withheld,omitempty"`
	// WithheldMembers are the files of an archive the page was that the
	// Voice Writer was not given, each with why; the archive's other files
	// are samples.
	WithheldMembers []string `json:"withheldMembers,omitempty"`
	// Bytes is the file fetched.
	Bytes int64 `json:"bytes"`
	// contains filtered or unexported fields
}

Page is one address a build was given, and what became of it.

func (*Page) Address added in v0.7.23

func (p *Page) Address() string

Address is the page's address as web_read opens it.

type PagesOptions added in v0.7.23

type PagesOptions struct {
	URLs []*sources.Source
	// Review is AI Review, which reads every fetched page's text before
	// the run.
	Review webscan.Scanner
	// NoRender, when set, is why a page drawn by scripts cannot be read
	// with web_read in this build; such a page is withheld with it.
	NoRender string
	Home     string
	Policy   *policy.Policy
	RunID    string
	// OutDir receives the fetch step's receipts.
	OutDir string
	// Work is a folder of the caller's under the runner home, removed by
	// the caller: the pages are fetched, decoded and staged beneath it.
	Work   string
	Stderr io.Writer
}

PagesOptions configure ReadPages: the addresses a built-in other than the Voice Writer is given (the Report Designer's), read exactly as a voice's are.

type PagesResult added in v0.7.23

type PagesResult struct {
	// Inputs is the folder holding the text of the pages AI Review passed
	// and documents.json, to be given to the run as one input; empty when
	// no page's text was staged.
	Inputs string
	// Docs are the documents staged there.
	Docs []decode.Document
	// Given are the addresses web_read may open: pages drawn by scripts.
	Given []string
	// Pages are the addresses given and what became of each.
	Pages []*Page
	// Decoded is the decode step's result, for the receipt.
	Decoded *decode.Result
}

PagesResult is what ReadPages read.

func ReadPages added in v0.7.23

func ReadPages(ctx context.Context, d dockerx.Client, o PagesOptions) (*PagesResult, error)

ReadPages fetches each address in the files container, checks what it brought with ClamAV and Hybrid Analysis, decodes it, and has AI Review read each page's text before the run, staging what passed under o.Work/pages as text inputs: the steps a voice's addresses take, for a build with addresses and no samples.

type Result

type Result struct {
	// Text is the VOICE.md the Voice Writer wrote, held to the format;
	// nil when it wrote none that holds.
	Text []byte
	// Envelope is the run's receipt; nil when the run never began.
	Envelope *receipt.Envelope
	// Decoded is the decode step over the samples; nil when there were
	// none (an Edit by its note alone).
	Decoded *decode.Result
	// Samples are the samples it was given, by name; Skipped those no
	// decoder could read; Cut those cut short or left out by MaxTextBytes.
	Samples, Skipped, Cut []string
	// Pages are the web addresses it was given, and what became of each.
	Pages []*Page
}

Result is what one build did.

func Build

func Build(ctx context.Context, d dockerx.Client, o Options) (*Result, error)

Build runs the Voice Writer for o.Job and returns what it wrote.

Jump to

Keyboard shortcuts

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