Documentation
¶
Overview ¶
Package agent assembles one dax session with agentkit: the model, the prompt frame, the AGENTS.md chain, the confirmation policy, MCP servers and compaction, recorded into an agentsession content-addressed store (RFC 0002), and the extensions that offer everything else (Options.Extensions; see package extension). The session knows no tool: dax's file tools and bash are dax-coding's, the sub-agents dax-agents', and so on. What the kit cannot express is wired here by hand beside it, each place saying why.
The package is pre-1.0 and its API may change between minor versions.
Index ¶
- Constants
- Variables
- func CaptureWarnings(w io.Writer) (restore func())
- func DefaultMCPTrustFile(dir string) string
- func DefaultRoot() string
- func DefaultUserDir() string
- func Describe(p agentturn.PendingCall) string
- func Drive(ctx context.Context, c agentturn.Control, r Rules, items ...openresponses.Item) (*agentturn.RunEnd, error)
- func GC(ctx context.Context, root string, sweep bool, grace time.Duration) (int, error)
- func Import(ctx context.Context, root, path string) (string, error)
- func List(ctx context.Context, root, dir string) ([]agentsession.Summary, error)
- func ListExecutor(ctx context.Context, root string, argv []string) (workspace.Descriptor, []agentsession.Summary, error)
- func ListExecutorURL(ctx context.Context, root, endpoint string) (workspace.Descriptor, []agentsession.Summary, error)
- func ListWorkspaceURL(ctx context.Context, root, baseURL string) (workspace.Descriptor, []agentsession.Summary, error)
- func Project(ctx context.Context, root, id, dir string) (string, error)
- func Refusal(callID, note string) agentturn.Answer
- func Repair(ctx context.Context, root, id string) (cas.RepairReport, error)
- func Secrets(exts []extension.Extension, keyEnv string, servers []MCPServer) []string
- func ServersWorkspaceOf(h agentsession.Header) (workspace.Descriptor, []string, bool)
- func Verify(ctx context.Context, root, id string) (int, []error, error)
- func Warnings() io.Writer
- type Controls
- type Executor
- type ExecutorOptions
- type Info
- type MCPServer
- type MCPServerInfo
- type Options
- type PeerRecord
- type Permission
- type Placement
- type Rules
- type Session
- func (s *Session) Abort()
- func (s *Session) AddMCP(ctx context.Context, name, command string) (string, error)
- func (s *Session) Agent() *agentturn.Agent
- func (s *Session) Answering() (done func())
- func (s *Session) Close() error
- func (s *Session) ContinueFrom(ctx context.Context, entryID string) error
- func (s *Session) ID() string
- func (s *Session) Info() Info
- func (s *Session) Omitted() []agentkit.Omission
- func (s *Session) OpenPeer(ctx context.Context, id string) (*PeerRecord, error)
- func (s *Session) Path() string
- func (s *Session) PeerConfig() agentturn.Config
- func (s *Session) Permissions(end *agentturn.RunEnd) []Permission
- func (s *Session) Prompt(ctx context.Context, items ...openresponses.Item) (*agentturn.RunEnd, error)
- func (s *Session) Queue(ctx context.Context, mode agentturn.QueueMode, items ...openresponses.Item) error
- func (s *Session) Record() agentsession.Follower
- func (s *Session) Recorder() *session.Recorder
- func (s *Session) RemoveMCP(label string) error
- func (s *Session) Reply(ctx context.Context, id string, answer agenttool.Answer) error
- func (s *Session) Resume(ctx context.Context, answers ...agentturn.Answer) (*agentturn.RunEnd, error)
- func (s *Session) RunContext(ctx context.Context) context.Context
- func (s *Session) SetModel(name string) error
- func (s *Session) SetThink(on bool) error
- func (s *Session) State() agentturn.State
- func (s *Session) Subscribe(fn func(context.Context, agentturn.Event) error) func()
- func (s *Session) SubscribeView(fn func(context.Context, agentturn.Event) error) (unsubscribe func())
- func (s *Session) Tools() []agentkit.ToolOrigin
- func (s *Session) Viewing() (done func())
- type UnhashedCause
Constants ¶
const DefaultViewGrace = 5 * time.Second
DefaultViewGrace is how long an A2A conversation's question waits for a view to come back once the last one has gone, when Options.ViewGrace is zero.
const Version = "0.1.0-dev"
Version is what the session header names as the harness version.
Variables ¶
var AtTerminal = agentturn.Trigger{Kind: "human", Source: "terminal"}
AtTerminal is the person at this terminal, as who answered a question: a front that takes the answer from them names it on Reply's context with agentturn.ContextWithAnswerer.
var ErrHeld = errors.New("calls held for approval when the session stopped wait for an answer")
ErrHeld is what Prompt returns while calls a stopped session held for approval wait for an answer: nobody has said whether they may run, so they are answered first, with Resume, and the prompt goes in as a steer of that run (Drive does both).
Functions ¶
func CaptureWarnings ¶
CaptureWarnings sends the warnings dax writes to w instead of standard error until what it returns is called. A front that takes the screen (the terminal client) collects them while it opens the session, to show before it does, and while it has the screen, to show after. They are what dax notes about the store and the session, what the extensions dax ships warn about, and what the executor's launcher writes to its standard error, cleaned. w may be written to from several goroutines at once.
func DefaultMCPTrustFile ¶ added in v0.0.26
DefaultMCPTrustFile is where the projects whose MCP servers the user trusted are kept: mcp-trust.json in dir, the user's dax directory.
func Describe ¶
func Describe(p agentturn.PendingCall) string
Describe is one line for the user: the call and why it is unanswered.
func Drive ¶
func Drive(ctx context.Context, c agentturn.Control, r Rules, items ...openresponses.Item) (*agentturn.RunEnd, error)
Drive is the human or autonomous plane as a controller that answers by rule: it prompts c with items and runs until the agent is idle, answering every permission with r.Permit and every question with r.Reply, and returns how the last run ended. It holds nothing but agentturn's control contract, so it drives a session in this process or one behind a wire alike. Calls a stopped session held for approval are put to r.Permit first, and items go in as a steer of the run that answers them.
func GC ¶
GC packs the store's loose objects, or with sweep repacks everything into one pack and drops what no session needs, sparing objects younger than grace. It returns the number of objects packed or removed. A dax holding a session may keep writing meanwhile.
func Import ¶
Import reads an RFC 0001 JSONL session, one an earlier dax wrote, into the store as the session's record, so -list, -resume and -verify reach it. It returns the session's ID.
func List ¶
List returns the sessions recorded under root whose tools acted in dir on this machine, newest first: those whose header records that workspace, and those recorded before dax wrote one whose cwd is dir. A session whose tools ran in an executor is not one of them, even when the executor's root is the same path; ListExecutor finds those. An empty dir lists every session.
func ListExecutor ¶ added in v0.0.19
func ListExecutor(ctx context.Context, root string, argv []string) (workspace.Descriptor, []agentsession.Summary, error)
ListExecutor returns the sessions of the project an executor started by argv serves, as DialExecutor would start it, without starting it: the workspace the latest session reached by that command recorded, and every session recorded in that workspace, newest first, whichever address reached it. A command no recorded session used lists nothing, and the descriptor is zero. Sessions recorded before dax wrote the address are not found.
The address stands for the machine it reached last: one that has since led to another (a tunnel pointed at another box) lists the latest one's project, and the others are still opened by ID.
func ListExecutorURL ¶ added in v0.0.19
func ListExecutorURL(ctx context.Context, root, endpoint string) (workspace.Descriptor, []agentsession.Summary, error)
ListExecutorURL is ListExecutor for an executor serving at endpoint, as DialExecutorURL reaches it.
func ListWorkspaceURL ¶ added in v0.0.28
func ListWorkspaceURL(ctx context.Context, root, baseURL string) (workspace.Descriptor, []agentsession.Summary, error)
ListWorkspaceURL returns the sessions of the project a workspace served at baseURL holds (`dax workspace`, reached by -workspace), without dialing it: the workspace the latest session recorded in a remote workspace at that URL names, its root the served root, and every session recorded in that workspace, newest first. A URL no recorded session used lists nothing, and the descriptor is zero. URLs are compared as config.WorkspaceRef writes them, the identity -workspace records, so spellings of one address are one; a URL stands for whatever serves there last, as an executor's address does. A workspace that dialled a session's hub (workspace.hub) is listed by the ref its tunnel records, config.TunnelRef of its name, which no served workspace's URL can be.
func Project ¶
Project writes a recorded session as an RFC 0001 JSONL file into dir, <id>.jsonl, for tools that read files rather than the store, such as agentsession show and verify. It returns the file's path.
func Refusal ¶ added in v0.0.12
Refusal is a person's refusal of a call, the model told so and, when note is not empty, why.
func Repair ¶
Repair rewrites a session whose log a crash or the disk damaged, so it opens again and the store can be swept: every record that still reads is kept, with the entries whose objects are whole, and the damaged log is kept beside it.
func Secrets ¶ added in v0.0.26
Secrets are the variables every child of a session loses whatever their names: the extensions' Secrets, the model's key's variable keyEnv, and each MCP server's TokenEnv and SecretEnv. A program that builds the session's workspace, or starts its executor, itself scrubs those environments of these, as dax's command line does, since Options.Workspace carries its own environment.
func ServersWorkspaceOf ¶ added in v0.0.32
func ServersWorkspaceOf(h agentsession.Header) (workspace.Descriptor, []string, bool)
ServersWorkspaceOf is the servers workspace a session's header records (Options.ServersWorkspace), by its kind and ref, and the servers it offered; false for a session that had none.
func Verify ¶
Verify rebuilds every model call recorded in a session and checks it against the stored request hash, then holds the path to the leaf to RFC 0001's records rules. It returns the number of responses checked and what failed.
func Warnings ¶ added in v0.0.29
Warnings is where dax warns, at the time of each write: standard error, or what CaptureWarnings sends them to while a front has the screen. A program warns there about what it runs beside a session (dax's own: the hub a session hosts for its workspace, whose connects, drops and refusals it reports), so its lines are held and shown with the session's and never written under a front.
Types ¶
type Controls ¶
type Controls interface {
// SetModel changes the model for later runs, sub-agents included.
SetModel(name string) error
// SetThink turns reasoning on or off for later runs.
SetThink(on bool) error
// AddMCP starts a stdio MCP server whose tools are offered from the
// next run as mcp__<name>__<tool>, returning the label RemoveMCP
// takes.
AddMCP(ctx context.Context, name, command string) (string, error)
// RemoveMCP closes a server AddMCP started.
RemoveMCP(label string) error
// Info is what the session is: its ID, where it is kept, the tools
// it was assembled with, what its instruction layers left out and
// its MCP servers.
Info() Info
}
Controls are dax's own controls of a session, beside agentturn's control contract: what a front's slash commands do and what its start lines show. They are a product's, not every agent's, so they are not part of the contract: the model and the reasoning setting, the MCP servers, and the session's assembly. A wire to a remote front carries them beside it (front/control's commands); the Session is their in-process implementation.
type Executor ¶ added in v0.0.6
type Executor struct {
// contains filtered or unexported fields
}
Executor is `dax execute` running elsewhere, connected: the extensions' tools served from a container or another host, where their calls run, their facts are read and their stamps are made and checked. A session given one (Options.Executor) builds no tool of an extension in this process; it decides each call under its own policy and sends it there. It is exported so that a program built on dax can start its session against a sandbox as dax's command line does with -executor. The caller closes it, after the session.
func DialExecutor ¶ added in v0.0.6
DialExecutor starts the program argv[0] with the arguments argv[1:], used exactly and with no shell, which runs `dax execute` where the tools are to act ({"docker", "exec", "-i", "box", "dax", "execute", "-root", "/work"}), and connects to it over its standard input and output. The pipe is the credential: there is no listener and no token. What it writes to standard error is cleaned and goes where dax warns at the time (CaptureWarnings). A program that is not a dax executor (one whose MCP server lacks the facts method or dax's capability, or lists tools the capability does not name) is refused and stopped.
When the pipe breaks (the program exits, its container restarts), the next request starts the program again, as the first was started, and goes on over the new pipe if it is the same executor: the same workspace, extensions and tools. A call in flight when it broke fails and is not sent again; the processes started there (the session's MCP servers) end with the old pipe and are not started again. Another executor is refused, and every call after fails until dax restarts. Either is a warning (CaptureWarnings).
func DialExecutorURL ¶ added in v0.0.18
DialExecutorURL connects to `dax execute -listen` serving at endpoint, an http or https URL, over MCP's streamable HTTP transport, and refuses what is not a dax executor as DialExecutor does. Nothing here starts it, so of o only Name, Version and MaxReadBytes apply. It sends no credential: whoever can reach the endpoint can run its tools, which is why `dax execute` listens on loopback unless told otherwise, and a tunnel (ssh -L) reaches it from elsewhere. The client pings it every executor.KeepAlive so an idle session stays open. When the connection is lost (the server restarted or closed the session, the tunnel dropped), the next request connects again, as DialExecutor's does.
func (*Executor) Close ¶ added in v0.0.6
Close ends the calls in flight and the connection, which stops the executor's process.
func (*Executor) Server ¶ added in v0.0.6
Server is the name and version the executor gave, its program's.
func (*Executor) String ¶ added in v0.0.6
String names the executor and where it acts, for a banner.
func (*Executor) Workspace ¶ added in v0.0.6
Workspace is the executor's workspace as this machine sees it: its root and descriptor, the executor's word for where its tools act, and its files, read-only, through the executor, which serves them confined to its workspace as its tools' reads are. The session reads the project's AGENTS.md and .dax/skills through it, and a program reads the project's .dax/config.json through it as dax's command line does. It cannot write, remove or run a command; the tools do that in the executor. It is a workspace.Starter whose Start starts the process in the executor (`dax execute`'s process methods), so the session's MCP servers run there, where the tools act; an executor that cannot start one (an older dax execute) refuses, and nothing starts on this machine in its place.
type ExecutorOptions ¶ added in v0.0.6
type ExecutorOptions struct {
// Name and Version are the program's, which the executor is told.
Name, Version string
// PassEnv and KeyEnv are Options' own: the command that starts the
// executor (a docker exec, an ssh) gets this machine's environment
// with credentials removed, except those PassEnv names, and never
// KeyEnv's variable, whatever names it, so the model's key never
// reaches the sandbox.
PassEnv []string
KeyEnv string
// Secrets name more variables that hold credentials (the
// extensions' Secrets: extension.SecretsOf). Like KeyEnv's, the
// command that starts the executor never gets them, whatever names
// them.
Secrets []string
// LauncherEnv names more variables the command that starts the
// executor is given, credentials included: ssh's SSH_AUTH_SOCK, the
// token a kubectl credential plugin reads. They are that command's
// alone; the session's tools and MCP servers run in the executor,
// with its environment, and never see them. Naming KeyEnv is an
// error.
LauncherEnv []string
// MaxReadBytes is the session's max_read_bytes, Options.MaxReadBytes
// as the executor's tools are to take it: the most bytes of a file
// they read, which the executor caps at its own -max-read-bytes.
// Zero is tool.DefaultMaxRead. The executor's tools are built when
// it is dialed, so it is given here, not in Options. When the
// executor caps it lower, or is a dax execute older than the
// setting and the setting is not the default, dax warns
// (CaptureWarnings).
MaxReadBytes int64
// Box, when set, is what the session asks of a box host (`dax box
// serve`, which makes the box the tools run in): a profile and its
// tightenings, as JSON, sent on every connection. Any other
// executor ignores it.
Box json.RawMessage
}
ExecutorOptions say how to start an executor and what to call the session to it.
type Info ¶
type Info struct {
// ID is the session's ID. Recorded is false for a session nothing
// is kept of (no store), whose ID names nothing after it closes.
ID string
Recorded bool
// Path is its directory in a local store; empty otherwise.
Path string
Tools []agentkit.ToolOrigin
Omitted []agentkit.Omission
// Workspace says where its tools act: the kind, the ref and the
// root.
Workspace workspace.Descriptor
// MCP are its MCP servers, each with where it runs and what it is
// for, listed the same wherever it runs.
MCP []MCPServerInfo
}
Info describes a session for a front's start lines.
type MCPServer ¶
type MCPServer struct {
// Name is the prefix of the server's tools.
Name string
// Command is the command line, split as a shell splits words with
// nothing expanded; no shell runs it.
Command string
// Host runs Command on this machine whatever the workspace, with
// this machine's environment scrubbed, even with an Executor: a
// server called independently of the sandbox.
Host bool
// URL is a streamable HTTP server called from this machine, in
// place of a command; TokenEnv names the variable whose token is
// sent to its origin alone, and which every child's environment
// loses.
URL, TokenEnv string
// Project says the project's config named the server: it starts only
// when the user trusts the project's set (Options.TrustMCP).
Project bool
// Description says what the server is for, for a person reading a
// list of servers.
Description string
// SecretEnv names variables a command's server is given from this
// process's environment, which every other child of the session
// loses (Secrets): it is started as a workspace's offered server is
// (agentworkspace's Offer), its output, standard output and standard
// error, redacted of their values before the session reads any of
// it. A secret stays on the machine whose environment holds it, so
// such a server must be placed on this machine (Host), never in a
// workspace; not for a project's server or a URL; and none may be
// KeyEnv, a TokenEnv, an extension's secret, a pass list's or a
// served workspace's token variable.
SecretEnv []string
// contains filtered or unexported fields
}
MCPServer is an MCP server to connect: a command's stdio server, or one at a URL.
type MCPServerInfo ¶ added in v0.0.32
type MCPServerInfo struct {
// Name is the prefix of its tools, mcp__<name>__<tool>.
Name string
// Placement is where it runs, and Where names that place: the
// workspace, as a session's warnings name one, or the URL's origin
// alone (urlPlace), since a hosted server's key is often in its
// path. Where is empty on this machine.
Placement Placement
Where string
// Description is what the config, or the workspace that offers the
// server, says it is for: text from whoever wrote it, which a front
// cleans before it shows it.
Description string
// Secrets says this session gives it secrets (MCPServer.SecretEnv)
// and starts it on this machine, redacting them from what it
// writes. A server a workspace offers is never marked, even one
// that holds secrets there: agentworkspace does not tell a client
// that an offered server does (agentworkspace#23).
Secrets bool
// Added is the label RemoveMCP takes, for a server AddMCP started;
// empty for one the session opened with.
Added string
}
MCPServerInfo is one of a session's MCP servers as Info.MCP lists it: the same fields wherever it runs.
type Options ¶
type Options struct {
// Name and Version are what the session calls its harness: in the
// system prompt, to the kit, and in the session header. Empty is
// dax and Version. A program built on dax gives its own.
Name, Version string
// Description is what the kit says the agent is; empty is dax's
// for dax, and a plain line for a program that named itself.
Description string
// Extensions are everything the session offers the model past
// itself, in order: dax's command line gives dax-coding, and
// dax-agents, dax-skills and dax-memory as the settings say. With
// none the model has no tools but MCP servers'.
Extensions []extension.Extension
// Streamer is the model; dax's command line builds one from the
// configuration.
Streamer openresponses.Streamer
// SubagentStreamer is the model the sub-agents' requests go through
// (extension.Env's SubagentModel); nil is Streamer. dax's command
// line gives one of its own when the sub-agents' prompt cache lives
// for another time than the main conversation's (subagent_cache_ttl).
// Compaction and an A2A caller's conversation go through Streamer.
SubagentStreamer openresponses.Streamer
// Model is the model name the requests carry.
Model string
// Fit is the reasoning effort to ask a model for in place of the
// one Think implies, from what its vendor says it takes; nil asks
// as configured. It is applied where each configuration is built,
// never to a request on its way out, so the session records the
// request that was sent.
Fit func(ctx context.Context, model string, want openresponses.ReasoningEffort) openresponses.ReasoningEffort
Think bool
// Effort is the reasoning effort Think asks for; empty is low.
Effort openresponses.ReasoningEffort
// Dir is the directory on this machine the session started in.
// With no Workspace it is where the tools act, as a
// workspace.Local. The project's instructions (AGENTS.md, an
// extension's project files such as .dax/skills) are read through
// the workspace, not from Dir; only when the workspace is Dir on
// this machine and Dir is below its repository's root are the
// AGENTS.md files between the two read from here.
Dir string
// Workspace is where the tools act and what the session records as
// its cwd and workspace: a container, a remote runtime, or this
// machine. Nil is a workspace.Local over Dir, with an environment
// scrubbed of credentials (PassEnv, KeyEnv), which the session
// closes; one given here is the caller's to close.
Workspace workspace.Workspace
// ServersWorkspace is a second workspace beside Workspace (or the
// executor's), whose offered servers (workspace.ServerProvider) the
// session connects and nothing else: a served or tunnelled one
// granted servers alone (config.ServersAlone), so a server holding a
// secret of another machine's is used while the tools act in the
// session's own workspace. Its servers are connected as the
// workspace's offered ones are, through mcpStart, under the same
// names, collisions, rules and restarts; no tool acts in it, no file
// of it is read, and its servers are recorded under its identity in
// the session's header. One that offers none, that is the
// workspace, or that grants more than servers (exec, which reads a
// running server's environment, or write, which changes its code)
// fails the session. It is the caller's to close, after the session.
ServersWorkspace workspace.Workspace
// Executor runs the extensions' tools elsewhere, in `dax execute`
// (DialExecutor), in place of building them in this process over a
// workspace: their calls, facts and stamps are the executor's, and
// the session records its workspace. Setting both Executor and
// Workspace is an error. Every extension with Tools must be one the
// executor runs, and no extension's matcher may give a served
// tool's subjects (the policy reads the executor only through the
// tools' facts). MCP servers start in the executor (its workspace
// is a workspace.Starter there), and an executor that cannot start
// one fails them, never starting them here. The project's files
// are read through it. It is the caller's to close, after the
// session.
Executor *Executor
// BoxConfine is the session's box.confine, with a box host in front
// of Executor: config.ConfineUnits or config.ConfineWorkspace has the
// policy take that box's tools as confined (confine.go), so a bare
// ask rule for them does not ask. Empty or config.ConfineOff, and
// any value without a box host's envelope, claims nothing.
BoxConfine string
// Store records the session: a store the caller opened, which it
// closes after the session; a remote one (agentsession RFC 0003)
// fits here as a local one does. Nil opens the content-addressed
// store at Root.
Store agentsession.Store
// Root is the local session store, a content-addressed store
// holding every project's sessions, used when Store is nil; both
// empty disables recording.
Root string
// Sync is when an append to the store at Root is durable before it
// returns: every append (the default), a response or a call's
// output and what came before it, or at Close.
Sync cas.SyncPolicy
// UserDir is the user's dax directory, ~/.dax: its AGENTS.md is
// read before the project's.
UserDir string
// Instructions is text of the user's own, from the config's
// instructions_file, added to dax's part of the system prompt.
Instructions string
// AgentsMD reads UserDir/AGENTS.md, AgentsMDGlobal and the
// AGENTS.md chain from the repository's root down to the
// workspace's root into the instructions (https://agents.md);
// never a file above the repository.
AgentsMD bool
// AgentsMDGlobal are the user's own instruction files for every
// session (the config's agents_md_global), read under AgentsMD
// after UserDir/AGENTS.md and before the chain, in order. They are
// paths on this machine whatever the workspace, since they are the
// user's and not the project's, and are not screened; a missing
// one is skipped.
AgentsMDGlobal []string
// Compact, when positive, is the estimated token budget above which
// the transcript is folded before a call.
Compact int
// CompactServer folds through the server's compaction endpoint
// (compact.New) instead of a local summary (compact.NewLocal).
CompactServer bool
// Policy is the user's and the project's rules; the session adds
// the extensions' (Settings.Shipped) and builds the policy that
// decides which calls run, ask or are refused. nil lets every call
// run, and the extensions' BeforeToolCall hooks are not run.
Policy *policy.Settings
// MCP are the MCP servers connected with the session, each offering
// its tools as mcp__<Name>__<tool>. A command's server runs in the
// workspace when it can start a process (workspace.Starter), at its
// root and with its environment, and otherwise on this machine; with
// an Executor it runs in the executor, and one that cannot start a
// process fails the session. A server placed on the host runs on
// this machine whatever the workspace, and one at a URL is called
// from this machine. The servers the workspace offers of its own
// (workspace.ServerProvider: a box host's units) are connected
// beside these. A project's servers start only when TrustMCP is set
// or the trust file holds their set for this workspace. Their stderr
// is dax's, cleaned.
MCP []MCPServer
// TrustMCP trusts the set of MCP servers the project's config names
// for this workspace, starts them, and records the trust in
// MCPTrustFile, so a later session of the project with the same set
// starts them without it (-trust-mcp).
TrustMCP bool
// MCPTrustFile is where the trusted sets are kept; empty is
// DefaultMCPTrustFile under DefaultUserDir.
MCPTrustFile string
// MaxReadBytes is the most bytes of a file a tool should read,
// which extension.ToolEnv carries; zero is tool.DefaultMaxRead.
// With an Executor, its tools take ExecutorOptions.MaxReadBytes,
// given when it was dialed, and not this.
MaxReadBytes int64
// PassEnv names credential-looking variables the processes of the
// workspace.Local the session opens when Workspace is nil, MCP
// servers among them, may still inherit; every other credential is
// removed from their environment. A workspace given in Workspace
// carries its own (Workspace.Env), and an MCP server that cannot
// start in it runs on this machine with an environment scrubbed the
// same way.
PassEnv []string
// KeyEnv is the variable the provider's key was read from. It is
// removed from the same environments even when its name does not
// look like a credential's, unless PassEnv names it, as are the
// variables the extensions name in Secrets.
KeyEnv string
// Log receives dax's own notes: compactions, denials, skill grants.
// nil discards them.
Log func(format string, args ...any)
// ViewGrace is how long an A2A caller's conversation's question
// waits for a view to attach again once the last has gone, as one
// reconnecting does, before it is given up; zero is
// DefaultViewGrace.
ViewGrace time.Duration
// contains filtered or unexported fields
}
Options configure a session.
type PeerRecord ¶ added in v0.0.17
type PeerRecord struct {
// contains filtered or unexported fields
}
PeerRecord is the record of one A2A caller's conversation: a dax session of its own in the session's store, listed and resumed as any other.
func (*PeerRecord) Attach ¶ added in v0.0.17
func (p *PeerRecord) Attach(ctx context.Context, a *agentturn.Agent, who string) (context.Context, func(), error)
Attach records a's runs in the conversation's session: the tools' records, the run's events, and on the context it returns the recorder the session's hooks write their verdicts with, the session for the model calls and memory, and who the questions of the run come from, which a front is told with each (who: the caller, say). detach undoes it once the run is over, and revokes the skill grants the run made, as the session's own end at its next message, so the kit keeps nothing for a conversation between its tasks.
type Permission ¶
type Permission struct {
Call *openresponses.FunctionCall
// Reason is the policy's question, with what it was asking about:
// the rule, the secret path, the git config key, the part of a
// command line.
Reason string
}
Permission is a call a run left for a person to answer.
func HeldPermissions ¶ added in v0.0.16
func HeldPermissions(c agentturn.Control) []Permission
HeldPermissions are the calls a stopped session left held for approval that wait on a person, as PermissionsOf reads them from a run's end: after a restart, each with the question and the part of the call the restored decision is about, and not the calls held only beside another's question, which Resume releases. A call whose decision did not survive is asked about as held when the session stopped.
func PermissionsOf ¶ added in v0.0.12
func PermissionsOf(c agentturn.Control, end *agentturn.RunEnd) []Permission
PermissionsOf are the calls a run that ended for input left for a person: the Session's own Permissions when c is one, and otherwise (a control behind a wire) the pending calls whose decision was not only held beside another's question, with the decision's question and the part of the call it is about.
type Placement ¶ added in v0.0.32
type Placement string
Placement is where one of a session's MCP servers runs, as Info.MCP lists it.
const ( // PlacedHost is a command on this machine: placed on the host, one // holding secrets, or one beside a workspace that cannot start a // process. PlacedHost Placement = "host" // PlacedWorkspace is a command started in the session's workspace: // this directory, an executor, a box, or a served or tunnelled // workspace whose grant runs commands. PlacedWorkspace Placement = "workspace" // PlacedURL is a streamable HTTP server, called from this machine. PlacedURL Placement = "url" // PlacedOffered is a server the session's workspace offers of its // own: a box host's unit, or a served or tunnelled workspace's // -servers. PlacedOffered Placement = "offered" // PlacedServersWorkspace is a server the servers workspace offers // (Options.ServersWorkspace). PlacedServersWorkspace Placement = "servers workspace" )
The placements an MCP server has. Whichever it is, the server is connected the one way (its tools mcp__<name>__<tool>, its restarts, its output cleaned), so a listing differs only in this.
type Rules ¶
type Rules struct {
// Permit decides a call the policy asked about: allow, or refuse,
// with a note the model is told either way. reason is the policy's
// question. Nil refuses every call.
Permit func(call *openresponses.FunctionCall, reason string) (allow bool, note string)
// Reply answers a question asked while a call runs: a sub-agent's
// call the policy asks about (q.Call), a tool's own question. What
// it says with the answer is its Note, which the model is told of an
// answer about a call. Nil leaves the questions unasked: a
// sub-agent's call is refused with a note to make it from the main
// agent, and a tool's question is cancelled.
Reply func(q agentturn.Question) agenttool.Answer
// Refused, when set, is told of each call Permit refused.
Refused func(call *openresponses.FunctionCall)
// By, when set, names who gave the reply Reply has just given to q,
// written beside the answer (agentturn.ContextWithAnswerer):
// AtTerminal for a person's answer, a trigger of the controller's
// own for a rule's. It is asked per reply, so rules that ask a
// person and answer for them when nobody can (a decline at the end
// of the input) name the person only for what the person said. The
// zero Trigger, or a nil By, leaves the reply unattributed.
By func(q agentturn.Question) agentturn.Trigger
}
Rules are an autonomous controller's answers: what Drive says to each question a run asks, in place of a person.
type Session ¶
Session is one dax conversation: the kit that assembled it, the in-process human plane over it (Backend), dax's own controls (Controls), and the store it is written to.
func Resume ¶
Resume reopens a recorded session and continues it from its leaf. Calls an earlier run left unanswered become pending on the agent, each with the reason the file's dispatch records give it, and are answered by the next Prompt.
func (*Session) AddMCP ¶
AddMCP starts a stdio MCP server mid-session and offers its tools from the next run as mcp__<name>__<tool>. It returns the label RemoveMCP takes.
func (*Session) Agent ¶
Agent is the session's one agent, for what the control contract does not carry: its configuration. Drive the session through the Session itself, whose rules a run on the agent would go around.
func (*Session) Answering ¶ added in v0.0.12
func (s *Session) Answering() (done func())
Answering says a front answers the questions asked while a call runs, until the returned func is called. With none answering, a question is not asked: a tool's is cancelled, and a sub-agent's call the policy asks about is refused with a note to make it from the main agent, where a run that ends for input can put it to the user.
func (*Session) ContinueFrom ¶ added in v0.0.12
ContinueFrom moves the session's head to the entry: the next prompt continues the conversation from there, on a branch of the session, with the skill grants of that branch (agentkit.Control.ContinueFrom).
func (*Session) Omitted ¶
Omitted is what the instruction layers considered and left out. A file of the AGENTS.md chain the kit left out is named by its path in the workspace's root, as the screening names one, where the kit names it within the workspace's file system.
func (*Session) OpenPeer ¶ added in v0.0.17
OpenPeer starts the session that records an A2A caller's conversation, or with id resumes the one that does. The session names the harness and the workspace's root as the served session does, so -list in the project shows it.
func (*Session) Path ¶
Path is the session's directory in the local store, its header, log and head; empty when not recording, or recording into a store that is not a local one.
func (*Session) PeerConfig ¶ added in v0.0.17
PeerConfig is the configuration an A2A caller's conversation runs under when the session's host serves A2A beside it (agentturn's front/a2a): the session's agent's, so the same model and reasoning, extensions, policy and workspace, read when it is called; its tools are the kit's, so an MCP server added or removed later is added or removed for the conversations too. A call the policy asks about, a sub-agent's asked call, or a tool's question, goes to the views attached to the session (Viewing), naming the caller's conversation (PeerRecord.Attach). With none attached it is not asked, and when the last one goes while it waits it is given up: the policy's question becomes a refusal, never an allow. Its ToolRecorder is nil; PeerRecord.Attach routes a run's records to the conversation's session.
The conversations share the workspace with the session, and with each other, as parallel sub-agents do.
func (*Session) Permissions ¶
func (s *Session) Permissions(end *agentturn.RunEnd) []Permission
Permissions are the calls a run that ended for input left for a person, each with the policy's question and the part of the call it is about: not the calls the engine holds beside them, which Resume releases.
func (*Session) Prompt ¶
func (s *Session) Prompt(ctx context.Context, items ...openresponses.Item) (*agentturn.RunEnd, error)
Prompt implements agentturn.Control, answering the calls an abort or a restart left unanswered first and refusing with ErrHeld while held calls wait.
func (*Session) Queue ¶ added in v0.0.12
func (s *Session) Queue(ctx context.Context, mode agentturn.QueueMode, items ...openresponses.Item) error
Queue implements agentturn.Control: each item is on the record, as a queued entry, before it returns.
func (*Session) Record ¶
func (s *Session) Record() agentsession.Follower
Record is the store the session is written to, as a view follows it (Follow from Info's ID), or nil for a store that cannot be followed. A session nothing is kept of is written to memory and followed the same way.
func (*Session) Recorder ¶ added in v0.0.12
Recorder is the recorder writing the session, for a view that follows it (agentconsole's client.RecordOf).
func (*Session) RemoveMCP ¶
RemoveMCP closes a server AddMCP started; its tools are not offered from the next run, and Info no longer lists it. The kit drops a server it added before it closes it, so a close that fails still leaves it unlisted.
func (*Session) Reply ¶
Reply implements agentturn.Control: it answers a question asked while a call runs. A question no longer waiting is an error. Who answered is the answerer ctx names (agentturn.ContextWithAnswerer), which the record writes beside the answer: a front names the person it took the answer from (AtTerminal), and a reply that names nobody is unattributed. The run's own context, which a Question event is delivered with, names who started the run, not who answers.
func (*Session) Resume ¶ added in v0.0.12
func (s *Session) Resume(ctx context.Context, answers ...agentturn.Answer) (*agentturn.RunEnd, error)
Resume implements agentturn.Control: the answers go through the kit's engine, which releases the calls it only held beside the ones asked about, and a pending call no one waits on is answered with what is known of it.
func (*Session) RunContext ¶
RunContext puts on ctx what the kit expects of a run it records: its recorder, the session's ID for the model calls, the session for memory a run writes and the reasoning attribution of the branch the head was last moved to (agentkit.Control.RunContext). Prompt and Resume use it.
func (*Session) SetModel ¶
SetModel changes the model name for later runs, with the reasoning fitted to it. The loop leaves the reasoning items another model produced out of the new model's requests, so a switch under -think sends no signature the new model refuses; the recorder writes those requests' responses unhashed.
The sub-agents follow it from their next call: a task with model main runs it, and so does every sub-agent when no sub-agent model is configured.
func (*Session) SetThink ¶
SetThink turns reasoning on or off for later runs, fitted to the model in force, and keeps the setting for a later SetModel. The sub-agents follow it from their next call.
func (*Session) Subscribe ¶
Subscribe implements agentturn.Control. The recorder subscribed first, so an entry is in the store before a subscriber sees the event that wrote it.
func (*Session) SubscribeView ¶ added in v0.0.17
func (s *Session) SubscribeView(fn func(context.Context, agentturn.Event) error) (unsubscribe func())
SubscribeView subscribes fn as a view attached (Viewing) until the returned func is called. The agent sends a new subscriber the questions still waiting first, so a view that reconnects, or attaches while an A2A conversation's question waits, is shown it.
func (*Session) Tools ¶
func (s *Session) Tools() []agentkit.ToolOrigin
Tools lists the tools the kit assembled, each with its source.
func (*Session) Viewing ¶ added in v0.0.17
func (s *Session) Viewing() (done func())
Viewing says a view is attached to the session, one that sees its events and can answer its questions, until the returned func is called. A host serving the session counts each follower of its events (SubscribeView). Answering says questions may wait for a view; Viewing says one is there, which an A2A caller's conversation needs: its questions are put only to a view attached when they are asked.
type UnhashedCause ¶
UnhashedCause is a reason the recorder wrote for leaving requests unhashed, and how many responses after it went without a hash.