mast

package module
v0.1.0-pre Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

README

mast

The agent-infrastructure substrate for unattended, library-embedded, multi-provider workloads. Lean fork of go-steer/core-agent.

Status: Phase 1 in progress (since 2026-07-26). The design corpus lives under docs/; the code rebuild has begun — the spike-validated prototype graduated in P1.1 (cmd/mast/, pkg/, GKE triage example, CI). Adapter ports from core-agent land when its code-cleanup milestones close (revised trigger in docs/fork-design.md).

What mast is

  • Headless / unattended. Runs as Cloud Run pods, Kubernetes services, scheduled monitors, daemons behind attach sockets.
  • Library-embeddable. A Go library you compile into your own service, not just a CLI.
  • Multi-provider. Same config, Claude or Gemini — switch without code changes.
  • Audit + governance first. Session DB, event log, permission gate, cost ceilings as first-class citizens.

What mast is not

  • Not a Claude Code competitor. Developer-laptop interactive coding is downstream of model + IDE + training investment we can't match. Use Claude Code, Antigravity, or Cursor for that shape.
  • Not a one-tool-for-everything. Sibling to core-agent under the (E) — sibling products with divergent agendas — motivation: mast targets platform-agent runtime; core-agent stays the experimentation + integration substrate (cogo-shaped consumers).
Repo Role
go-steer/core-agent Parent project. Until the fork executes, mast's code lives there. Stays alive as the experimentation/integration substrate.
go-steer/mast-web Operator-facing web UI for mast (and any attach-mode core-agent variant). Already initialized; ships independently.
go-steer/core-tui Terminal UI alternative for developer / experimentation workflows. Stays paired with core-agent, not mast.

Contributing pre-fork

Right now this repo accepts docs PRs only. Substantive design changes welcome; code lands here when the fork executes (the trigger condition is documented in docs/fork-design.md, revised 2026-07-26 — paraphrased: the rebuild work starts immediately; only the adapter ports wait on core-agent's code cleanup milestones closing).

For code-level changes that anticipate landing in mast post-fork, open the PR against core-agent and reference the relevant docs/ design here.

License

Apache 2.0 — see LICENSE.

Documentation

Overview

Package mast is the top-level convenience API for embedding the mast agent runtime in a Go program — the 90% path for library-embedded consumers (docs/library-api-design.md, "Top-level convenience API"). It delegates to the pkg/ subsystems for everything; no type defined here duplicates a subsystem type: workloads are pkg/workload.Bundle, specialists are pkg/specialists.Spec, session projections are pkg/session values, budget ceilings are pkg/budget.Limits.

Stability

This package is one of the five stable-from-v0.1 surfaces (docs/library-api-design.md, import-surface table): it follows semver, and breaking changes get a deprecation cycle. The v0.1 surface is deliberately minimal — Config, Result, Run, RunWorkload, ListSessions, ResumeSession; server mode, lifecycle hooks, and option-func variants land in later versions.

Slim consumers

This is the batteries-included surface: it imports the dispatch subsystems (pkg/graph, pkg/router, pkg/planner), several of which are denylisted for the slim-embed guarantee. Consumers who need the minimal dependency graph (docs/library-api-design.md, "Slim-embed guarantee") must NOT import this package — they compose the slim slice directly (pkg/agent, pkg/specialists, optionally pkg/workload, pkg/budget, pkg/session), as examples/deploy/slim does.

Example

Programmatic bundle registration, no filesystem:

res, err := mast.RunWorkload(ctx, mast.Config{ModelName: "echo"},
    workload.Bundle{Name: "triage", Specialists: []string{"classify", "_fallback"}},
    []specialists.Spec{
        {Name: "classify", Mode: specialists.ModeSingleTurn, Instruction: "..."},
        {Name: "_fallback", Mode: specialists.ModeTask, Instruction: "..."},
    },
    `{"reason":"CrashLoopBackOff"}`)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListSessions

func ListSessions(ctx context.Context, cfg Config) ([]session.Summary, error)

ListSessions returns the operator projections (pkg/session) for every session in Config.Sessions under mast's app name: state (paused/aborted/idle), pending interrupt IDs, last-event times. Thin delegation to pkg/session's Store; use that package directly for detail views and abort markers.

Types

type Config

type Config struct {
	// Model is an explicit ADK model to drive every agent. Takes
	// precedence over ModelName. Use this to inject a custom or fake
	// model.LLM.
	Model model.LLM

	// ModelName constructs a built-in model when Model is nil: "echo"
	// (in-process fake, no credentials — the testing surface) or a
	// "gemini-*" model id (Vertex/Gemini via ADK). It also selects the
	// usage pricing rate; when Model is set and ModelName is empty,
	// pricing falls back to Model.Name().
	ModelName string

	// Sessions is the ADK session service runs execute against. Nil
	// means a fresh in-memory service per call — no durability, and no
	// resume across calls. Pass a shared service (ADK's
	// session/database over SQLite/Postgres, or one InMemoryService
	// reused across calls) to get durable pause/resume and
	// ListSessions.
	Sessions adksession.Service

	// Logger receives construction and turn logs. Nil disables
	// logging.
	Logger *slog.Logger

	// Budget overrides the budget ceilings for the run. Nil derives
	// limits from the workload bundle's budget block (Run has no
	// bundle, so nil means unlimited). A zero RatePer1K is filled from
	// the model's flat spike pricing so Result.Usage.CostUSD is never
	// silently zero-rated.
	Budget *budget.Limits
}

Config bundles the common knobs for Run/RunWorkload/ResumeSession. The zero value is not runnable: a model (Model or ModelName) is required. Everything else defaults sensibly — in-memory sessions, no logging, bundle-derived budget.

type Result

type Result struct {
	// Output is the turn's final output: the last node output or model
	// text the runner emitted. When the turn parked on a HITL
	// interrupt, Output holds whatever the run produced before
	// pausing; inspect ListSessions for the pending interrupt.
	Output string

	// SessionID identifies the session the turn ran in. Pass it to
	// ResumeSession (with a durable Config.Sessions) to continue a
	// paused run.
	SessionID string

	// Usage is the session's cumulative usage after the turn.
	Usage Usage
}

Result is the outcome of one library-run turn.

func ResumeSession

func ResumeSession(ctx context.Context, cfg Config, bundle workload.Bundle, specs []specialists.Spec, sessionID, interruptID string, response any) (*Result, error)

ResumeSession feeds an operator verdict back into a session that parked on a HITL interrupt (a durable RequestInput; see session.Detail.Pending for pending interrupt IDs and response schemas). bundle and specs must describe the same workload the session was started with — the resume turn is executed by a runner over the same root shape — and Config.Sessions must be the service (or database) holding the session.

The wire shape is the spike-2-verified resume contract: a user turn carrying a FunctionResponse whose ID equals the pending interrupt ID, with response under the "response" key. Sessions carrying an operator abort marker are refused.

func Run

func Run(ctx context.Context, cfg Config, instruction, input string) (*Result, error)

Run is the single-agent convenience: one Chat-mode agent with the given system instruction, one turn on input. No workload, no specialists, no dispatch — the "hello world" of embedding mast.

func RunWorkload

func RunWorkload(ctx context.Context, cfg Config, bundle workload.Bundle, specs []specialists.Spec, input string) (*Result, error)

RunWorkload executes one turn of a programmatically-registered workload: bundle and specs are plain values (the same types pkg/workload and pkg/specialists loaders produce from files — no filesystem is touched here), input is the turn's user message.

The dispatch shape is chosen from the roster, mirroring cmd/mast's semantics: the supervisor-body planner when bundle.Planner.Enabled; the workflow-graph LLM-as-router when the roster carries a SingleTurn classifier and a "_fallback" Task specialist; the SubAgents coordinator otherwise.

The bundle's budget block (or Config.Budget) is enforced while the turn streams; crossing a ceiling aborts the run with an error wrapping budget.ErrExceeded. bundle.Budget.MaxWallclockSeconds bounds the whole turn.

type Usage

type Usage struct {
	// Tokens is the total token count across all model calls.
	Tokens int64
	// CostUSD is the derived cost (flat spike pricing; see pkg/budget).
	CostUSD float64
	// ModelCalls is the number of model calls ("turns" in mast's
	// budget vocabulary).
	ModelCalls int
}

Usage is the run's cumulative usage snapshot, taken from the pkg/budget meter after the turn completes.

Directories

Path Synopsis
cmd
mast command
Command mast is the entry point for the mast agent runtime.
Command mast is the entry point for the mast agent runtime.
examples
deploy/slim command
Command slim is the reference consumer for the slim-embed guarantee (docs/library-api-design.md, "Slim-embed guarantee"): a single-file host service embedding exactly one mast control loop in-process — a SingleTurn classifier feeding one Task specialist — with in-memory sessions and nothing else.
Command slim is the reference consumer for the slim-embed guarantee (docs/library-api-design.md, "Slim-embed guarantee"): a single-file host service embedding exactly one mast control loop in-process — a SingleTurn classifier feeding one Task specialist — with in-memory sessions and nothing else.
workflows/fan-out-fan-in command
Command fan-out-fan-in is the forkable starter for workflow shape #1 (fan-out-fan-in) from docs/workflow-scaffolding-design.md:
Command fan-out-fan-in is the forkable starter for workflow shape #1 (fan-out-fan-in) from docs/workflow-scaffolding-design.md:
workflows/llm-as-router command
Command llm-as-router is the forkable starter for workflow shape #7 (LLM-as-router) from docs/workflow-scaffolding-design.md:
Command llm-as-router is the forkable starter for workflow shape #7 (LLM-as-router) from docs/workflow-scaffolding-design.md:
internal
compose
Package compose wires a workload bundle plus its specialist specs into a runnable root agent.
Package compose wires a workload bundle plus its specialist specs into a runnable root agent.
pkg
a2a
Package a2a implements the v0.1 synchronous A2A client from docs/a2a-design.md ("Mast as A2A client", client-only phasing row): agent-card discovery and caching, JSON-RPC 2.0 message/send on the single A2A v0.3 endpoint (A2A-Version header, bearer auth from an env-var reference), direct-message and task-opened reply handling with bounded tasks/get polling to a terminal state, and tasks/cancel on caller cancellation.
Package a2a implements the v0.1 synchronous A2A client from docs/a2a-design.md ("Mast as A2A client", client-only phasing row): agent-card discovery and caching, JSON-RPC 2.0 message/send on the single A2A v0.3 endpoint (A2A-Version header, bearer auth from an env-var reference), direct-message and task-opened reply handling with bounded tasks/get polling to a terminal state, and tasks/cancel on caller cancellation.
agent
Package agent provides the bucket-1 shim over ADK v2's runner and llmagent primitives.
Package agent provides the bucket-1 shim over ADK v2's runner and llmagent primitives.
budget
Package budget meters model usage against workload budget ceilings.
Package budget meters model usage against workload budget ceilings.
config
Package config implements v0.1 of the `.agents/` discovery and loading rules from docs/config-layout-design.md.
Package config implements v0.1 of the `.agents/` discovery and loading rules from docs/config-layout-design.md.
envelope
Package envelope defines the on-the-wire payload shapes mast accepts on its inject endpoint.
Package envelope defines the on-the-wire payload shapes mast accepts on its inject endpoint.
federation
Package federation implements the v0.1 slice of docs/federation-design.md: the frozen Adapter interface, reference parsing for `<scheme>://<name>[/<skill>]` remote-agent references, a scheme-keyed adapter registry, and the planner-facing `invoke_remote_agent` tool.
Package federation implements the v0.1 slice of docs/federation-design.md: the frozen Adapter interface, reference parsing for `<scheme>://<name>[/<skill>]` remote-agent references, a scheme-keyed adapter registry, and the planner-facing `invoke_remote_agent` tool.
graph
Package graph assembles the workload's triage flow as an explicit ADK v2 workflow graph — the LLM-as-router shape from docs/workflow-scaffolding-design.md (#7), as sketched in docs/triage-demo-plan.md:
Package graph assembles the workload's triage flow as an explicit ADK v2 workflow graph — the LLM-as-router shape from docs/workflow-scaffolding-design.md (#7), as sketched in docs/triage-demo-plan.md:
inject
Package inject implements the HTTP endpoint that receives edge-trigger payloads (from k8s-event-watcher and any other source speaking the envelope.InjectPayload shape) and dispatches them into the mast runtime.
Package inject implements the HTTP endpoint that receives edge-trigger payloads (from k8s-event-watcher and any other source speaking the envelope.InjectPayload shape) and dispatches them into the mast runtime.
mcp
Package mcp wires MCP toolsets for the workloads mast ships.
Package mcp wires MCP toolsets for the workloads mast ships.
observability
Package observability holds mast's telemetry surface: the FIXED Prometheus metric registry, and env-gated OTel trace-export setup.
Package observability holds mast's telemetry surface: the FIXED Prometheus metric registry, and env-gated OTel trace-export setup.
planner
Package planner implements the v0.1 scaffold of the supervisor-body planner from docs/orchestration-design.md ("The planner", shape C with light D flavor): a Task-mode LlmAgent whose tool vocabulary is the workload's execution vocabulary.
Package planner implements the v0.1 scaffold of the supervisor-body planner from docs/orchestration-design.md ("The planner", shape C with light D flavor): a Task-mode LlmAgent whose tool vocabulary is the workload's execution vocabulary.
router
Package router assembles the top-level agent for a workload: a Chat-mode coordinator with the workload's specialists as SubAgents.
Package router assembles the top-level agent for a workload: a Chat-mode coordinator with the workload's specialists as SubAgents.
session
Package session is the operator-facing read/inspect surface over ADK's session store (docs/durable-execution-design.md, "Operator-facing surface").
Package session is the operator-facing read/inspect surface over ADK's session store (docs/durable-execution-design.md, "Operator-facing surface").
specialists
Package specialists loads specialist .tmpl files from disk and turns them into ADK v2 agents.
Package specialists loads specialist .tmpl files from disk and turns them into ADK v2 agents.
workload
Package workload loads workload bundles — the declarative operational profile for a mast deployment.
Package workload loads workload bundles — the declarative operational profile for a mast deployment.

Jump to

Keyboard shortcuts

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