api

package
v0.1.0-rc2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package api is the public, stable surface for embedding agentsmithy into other Go programs (notably smithy-cli). It re-exports the small set of operations needed to load config, run a server, or chat with an agent, all without depending on the internal/* packages.

Index

Constants

View Source
const ExitError = tmpl.ExitError

ExitError is the ExitKind for error exits.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(path string) (*config.Config, string, error)

LoadConfig reads and parses the config file at path and returns the parsed config along with the resolved project root (the directory containing the file).

func Serve

func Serve(ctx context.Context, cfg *config.Config, opts ServeOptions) error

Serve builds the pipeline from cfg and runs it on the requested transport. It blocks until ctx is cancelled or the transport terminates. Used both by `agentsmithy serve` and by smithy-cli when it embeds the binary in-process.

Types

type ExitSignal

type ExitSignal = tmpl.ExitSignal

ExitSignal is a sentinel error returned when an agent calls {{ exit_error "reason" }}. Callers use errors.As to detect it.

type ServeOptions

type ServeOptions struct {
	// Root is the directory the server is rooted in.
	Root string
	// Transport is the wire protocol; one of none|stdio|mcp-stdio|a2a|mcp-http.
	Transport string
	// Addr is the listening address for HTTP-style transports.
	Addr string
	// Once, when non-empty and Transport is stdio, sends a single prompt and exits.
	Once string
	// Verbose enables tool-call/intermediate-step tracing on stdio.
	Verbose bool
}

ServeOptions controls server behaviour.

Transport selects the wire protocol:

  • stdio: line REPL over stdin/stdout for dev/CI use.
  • mcp-stdio: agent exposed as an MCP tool over stdin/stdout (the transport VS Code, Claude Desktop, etc. spawn). Required for `provider: borrowed`.
  • mcp-http: same MCP surface over streamable HTTP.
  • a2a: A2A JSON-RPC server over HTTP, with AgentCard at /.well-known/agent.json.

Jump to

Keyboard shortcuts

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