Documentation
¶
Overview ¶
Package tacklr is the harness: Harness runs one session's steps (a model request through Model, a tool call with its CallContext, a commit into the window), and the root package owns tool registration, the window and plan, the checkpoint encoding, and the VFS, brain and MCP wiring. Other packages:
- message holds the conversation data (Message, ContentPart, ToolCall).
- session is the client contract (Client, Store, Event); session/orchestrator decides each step of a session over an orchestrator.Runtime; session/temporal is the Temporal client and session/temporal/worker its worker.
- brain owns knowledge retrieval; brain/postgres and brain/helixgraph are the store and graph adapters.
- vfs owns virtual filesystem mounts and the backend constructors; vfs/mount holds the mount bindings a client sends.
- anthropic and openai are the model clients (Claude, and OpenAI-compatible endpoints); web holds optional host tools.
- mcp owns MCP connection configuration.
Process-wide registrations (built-in interrupts, common VFS codecs) run in this package's init. Hosts import tacklr once; they do not register those defaults themselves.
New APIs should use the canonical domain packages and must not add server transport, wire protocol, persistence backend, or provider-client details here.
Index ¶
- Constants
- Variables
- func ChildID(parent, name, callID string, specialist bool) string
- func ContextWithToolChoiceNone(ctx context.Context) context.Context
- func Correction(cause error, msg string) error
- func Correctionf(cause error, format string, args ...any) error
- func EpisodeKinds() []brain.KindSpec
- func IsPlanDocument(m *message.Message) bool
- func Network(err error) error
- func PipeEvents(emit func(session.Event)) (chan session.Event, func())
- func RegisterDefaults()
- func RegisterInterrupt(factory func() Interrupt)
- func ResolveToolTitle(displayName, toolName, argsJSON string) string
- func ResultText(body []byte) (string, error)
- func ToolChoiceNone(ctx context.Context) bool
- func TypeToJSONSchema(v any) (map[string]any, error)
- func UnsupportedMIMEs(s Model, mimes []string) []string
- func ValidateMessages(messages []*message.Message) error
- type AgentOptions
- type AuthExpired
- type Call
- type CallBody
- type CallContext
- func (cc *CallContext) CancelJob(_ context.Context, id string) error
- func (cc *CallContext) CurrentToolCallID() string
- func (cc *CallContext) EmitUpdate(message string)
- func (cc *CallContext) Jobs() []Job
- func (cc *CallContext) Park(intr Interrupt) (Interrupt, error)
- func (cc *CallContext) Schedule(_ context.Context, job JobRequest) (Job, error)
- func (cc *CallContext) StateDelete(key string)
- func (cc *CallContext) StateGet(key string) (any, bool)
- func (cc *CallContext) StateSet(key string, value any) error
- type CommitIn
- type Harness
- func (a *Harness) Checkpoint() ([]session.CheckpointEntry, error)
- func (a *Harness) Close()
- func (a *Harness) Commit(ctx context.Context, in CommitIn, out chan session.Event) error
- func (a *Harness) Infer(ctx context.Context, out chan session.Event) (Reply, error)
- func (a *Harness) RestoreCheckpoint(rows []session.CheckpointEntry) error
- func (a *Harness) RunCall(ctx context.Context, c Call, out chan session.Event) (Call, error)
- type Interrupt
- type Job
- type JobRequest
- type JobStart
- type LLMResponseChunk
- type Model
- type ModelRequest
- type OnCallFunc
- type Overflow
- type Park
- type PermissionOption
- type Reply
- type Round
- type Specialist
- type Todo
- type TodoStatus
- type Tool
- type ToolAccess
- type ToolCallFunc
- type ToolConfig
- type ToolHandlerFunc
- type ToolInterceptor
- type ToolInvocation
- type ToolOutcome
- type ToolPermission
- type ToolPermissionInterrupt
- type ToolPermissionPayload
- type ToolResultEffect
- type UserChoice
- type UserSelectionInterrupt
- type UserSelectionPayload
Constants ¶
const ( PermissionAllowOnce = "allow_once" PermissionAllowAlways = "allow_always" PermissionRejectOnce = "reject_once" PermissionRejectAlways = "reject_always" )
ACP PermissionOptionKind values.
const CancelledToolResultContent = "cancelled: user interrupted the agent"
CancelledToolResultContent is the result of a call that a new user message cancelled before it had one.
const JobRunning = "running"
JobRunning is a listed job's state. Jobs lists only running jobs: a finished one leaves the list when its result arrives. A specialist child waiting for input stays running.
const KindEpisode = "Episode"
KindEpisode is the kind a blocking specialist's result is kept as, so later sessions in the namespace can find it.
const TypeAuthExpired = "auth_expired"
TypeAuthExpired parks a tool call until the host rebinds credentials on Resume.Auth.
Variables ¶
var ( ErrInterruptNotFound = errors.New("interrupt not found") ErrInvalidPayload = errors.New("invalid payload") )
var ( ErrNotFound = errors.New("not found") ErrInvalid = errors.New("invalid") ErrFailed = errors.New("failed") ErrCorrection = errors.New("correction") ErrAuthExpired = errors.New("auth expired") )
Coarse categories for errors.Is. Wrap a specific message at the call site (fmt.Errorf("tool %q: %w", name, ErrNotFound)) instead of a sentinel per situation. Named sentinels below are distinct handling branches, not children of these categories.
ErrCorrection is a model-facing tool failure: Error() is the correction the model should follow. Construct with Correction(cause, msg). Distinct from ErrFailed (harness/runtime). errors.Is matches both ErrCorrection and cause.
var ( ErrModelAfterTools = errors.New("model request failed after tools completed") ErrApiKeyNotSet = errors.New("api key not set") ErrModelNotSet = errors.New("model not set") ErrUnknownModel = errors.New("unknown model") // ErrCannotCount is a CountTokens error: the provider has no way to // count a request's tokens. The harness then sizes requests from the // input tokens the provider reports for each response. ErrCannotCount = errors.New("the model cannot count tokens") ErrToolTimeout = errors.New("tool timed out") ErrToolPermissionDenied = errors.New("tool permission denied") )
var ErrNetwork = errors.New("network")
ErrNetwork is a transport failure: the dial, the read, a timeout, or an upstream 408, 429, or 5xx. Wrap it at the call that hit the network. The durable runtime retries a wrapped network error. Any other error stops on the first attempt.
Functions ¶
func ChildID ¶ added in v0.5.0
ChildID is the id of the child a tool call starts: a specialist session or a named Runtime job. It comes from the call, so a call that runs again names the same child. The harness and every runtime use it.
func ContextWithToolChoiceNone ¶ added in v0.3.4
ContextWithToolChoiceNone asks the provider to keep tool definitions on the wire but not call them. Handoff and compress use this so the cached tools prefix matches a normal turn.
func Correction ¶ added in v0.2.0
Correction wraps cause with model-facing correction text. msg is Error(); errors.Is matches ErrCorrection and cause. A nil/empty msg uses cause.Error().
func Correctionf ¶ added in v0.2.0
Correctionf is Correction with fmt.Sprintf.
func EpisodeKinds ¶ added in v0.3.4
EpisodeKinds are SDK-owned kinds. Hosts with a non-empty catalog pass them to ApplyKinds (as with vfsindex.MountIndexKinds).
func IsPlanDocument ¶ added in v0.3.4
IsPlanDocument reports the durable PROJECT PLAN developer message.
func Network ¶ added in v0.4.0
Network marks err as a transport failure. The text stays err.Error().
func PipeEvents ¶ added in v0.5.0
PipeEvents copies channel events to emit. Durable backends adapt emit callbacks to the harness chan session.Event API.
func RegisterDefaults ¶ added in v0.4.0
func RegisterDefaults()
RegisterDefaults registers the built-in interrupt types. Safe to call more than once. init calls this. NewInterrupt also ensures defaults so a checkpoint can rehydrate before any tool runs.
func RegisterInterrupt ¶
func RegisterInterrupt(factory func() Interrupt)
RegisterInterrupt registers a custom interrupt factory for session rehydrate.
func ResolveToolTitle ¶
ResolveToolTitle fills {param} in DisplayName from top-level string args. Empty displayName → toolName. Missing/non-string args → empty slot.
func ResultText ¶ added in v0.5.0
ResultText is the result text in an encoded body: what the call's tool-result event carried. It reads nothing else, so a reader that does not run the harness (a session client) needs none of its types.
func ToolChoiceNone ¶ added in v0.3.4
ToolChoiceNone reports whether ctx was wrapped with ContextWithToolChoiceNone.
func TypeToJSONSchema ¶
TypeToJSONSchema builds a JSON Schema for v. Prefer NewTool typed handlers for tools; this is mainly for structured model output.
func UnsupportedMIMEs ¶
UnsupportedMIMEs returns mimes for which s.SupportsMIME is false (first-seen order).
func ValidateMessages ¶ added in v0.2.0
ValidateMessages validates structural invariants shared by live context and durable checkpoints. Open assistant tool calls are valid while interrupted; pairing is repaired by the harness before the next model invocation.
Types ¶
type AgentOptions ¶
type AgentOptions struct {
// MaxWindowSize is the context window in tokens. Zero uses the model's
// reported window.
MaxWindowSize uint
SystemPrompt string
Model Model
// Name is the label used in logs. It does not select behavior.
Name string
// Tools are host tools, including optional tools from web, shell and
// workspace. Give each tool its clients by closing over them in the
// constructor (see NewTool). The plan, brain and specialist tools inject
// from the fields below.
Tools []*Tool
// MCP connects the harness to MCPConfigs (package mcp). It is
// required when there are MCP servers.
MCP session.MCPClient
MCPConfigs []session.MCPServer
// MCPCredentialResolver resolves durable references immediately before
// connection. Inline client credentials remain session-scoped.
MCPCredentialResolver session.MCPCredentialResolver
Specialists []*Specialist
// Overflow keeps the full text of results the window trims. When a round
// is too large for the window even with the history fully summarized,
// its largest results are trimmed; each one's full text is first kept
// here and the trimmed result says where. Nil: the full text is not kept.
Overflow Overflow
// ToolInterceptors wrap each tool call (outermost first). Built-in
// planning lock and OnCall middleware are installed after these.
// Hosts cannot omit the planning lock; specialists skip it via WithSpecialist.
ToolInterceptors []ToolInterceptor
// AllowTools are tools (by the name the model calls them, namespace__name
// for a namespaced tool) that run without a permission prompt. A user's
// reject-always still wins. An unknown name fails construction.
AllowTools []string
// SkillsLoader loads the skills the agent can read: skills.Loader for a
// local directory, or the workspace's skills directory (package
// workspace). Nil: no skills.
SkillsLoader skills.SkillLoader
// Brain enables the knowledge tools (search, open, related, save, and
// link when the engine has a graph) when non-nil. Workers inherit the
// same engine. The host builds the store, and the graph with
// brain.WithGraph, each with its own embedding, and passes the engine
// before NewHarness. The harness does not construct backends.
Brain *brain.Engine
// BrainWriteKinds are the kinds the save tool may write; it lists them
// as its kind choices. Empty: no save tool. Register them with
// brain.WithKinds or ApplyKinds. Ignored when Brain is nil.
BrainWriteKinds []string
// SearchNamespace is the host ceiling for brain tools: the widest
// namespace a session may read or write. Each tool call may add attrs
// to narrow it; it cannot change ceiling values. Required when Brain is
// set, unless SessionScope gives each session its own. Specialists get
// a copy.
SearchNamespace brain.Namespace
// SearchPrincipals are the caller's identities (user and group ids) checked
// against object Readers, so search only returns source files the caller can
// open at the source.
SearchPrincipals []string
// SessionScope, when set, gives each session its own brain scope. The
// runtime calls it with the session's id when it builds the session's
// harness and when it deletes the session's messages. The scope's
// Namespace and Principals replace SearchNamespace and SearchPrincipals
// for that session. Use it when one agent serves many tenants or users.
// A child session's id starts with its parent's id (ChildID), so the
// host can give a child its parent's scope. An error fails the step
// that asked.
SessionScope func(ctx context.Context, sessionID string) (brain.Scope, error)
// contains filtered or unexported fields
}
AgentOptions is the one agent, and the argument to NewHarness. A session runtime calls BindTurn to attach the session id for each turn. The agent's workspace (package workspace) adds its tools, skills and Overflow to these options for the turns that have one.
func BindTurn ¶ added in v0.4.0
func BindTurn(opts AgentOptions, id string, jobs []string) AgentOptions
BindTurn attaches the per-turn session id and the names of the Runtime job workers the runtime registered. The session runtime calls BindTurn.
func (*AgentOptions) Validate ¶ added in v0.2.0
func (opts *AgentOptions) Validate() error
Validate checks the construction contract and fills MaxWindowSize from the model when the host left it at zero.
func (AgentOptions) WithSpecialist ¶ added in v0.2.0
func (o AgentOptions) WithSpecialist(spec *Specialist) AgentOptions
WithSpecialist overlays a worker spec onto the parent session world. The child keeps parent MCP, brain, interceptors, and the turn binding from BindTurn. Model, tools, nested workers, and instructions come from spec. Planning write lock is off. The session runtime opens a new tree for the child.
type AuthExpired ¶ added in v0.3.1
type AuthExpired struct {
Tool string `json:"tool,omitempty"`
Provider string `json:"provider,omitempty"`
}
AuthExpired is raised when a tool or VFS mount unwraps to expired credentials. Return is a no-op; tokens travel on Resume.Auth, not the interrupt payload.
func (*AuthExpired) Error ¶ added in v0.4.0
func (p *AuthExpired) Error() string
func (*AuthExpired) Return ¶ added in v0.4.0
func (p *AuthExpired) Return([]byte) error
func (*AuthExpired) Serialize ¶ added in v0.4.0
func (p *AuthExpired) Serialize() ([]byte, error)
func (*AuthExpired) TypeName ¶ added in v0.4.0
func (p *AuthExpired) TypeName() string
type Call ¶ added in v0.5.0
type Call struct {
Tool message.ToolCall `json:"tool"`
Timeout time.Duration `json:"timeout,omitempty"`
Done bool `json:"done,omitempty"`
Park *Park `json:"park,omitempty"`
Await string `json:"await,omitempty"`
// Starts and Cancels are the jobs the call's last run started and
// stopped; the session starts and stops them.
Starts []JobStart `json:"starts,omitempty"`
Cancels []string `json:"cancels,omitempty"`
// The next run's input, which the session sets: the answer to the
// call's park, the result of the job it waits on, and the session's
// running jobs with how many it may run at once (zero: no limit). A run
// clears them.
Answer []byte `json:"answer,omitempty"`
JobEnd *session.JobResult `json:"jobEnd,omitempty"`
Jobs []string `json:"jobs,omitempty"`
MaxJobs int `json:"maxJobs,omitempty"`
Body *CallBody `json:"body,omitempty"`
// Err is why the call's step failed, when it did: not the tool's own
// failure, which is the call's result. It does not travel.
Err error `json:"-"`
}
Call is one tool call of a reply, through its whole life: what the model asked, what its runs did, and the input of its next run. It is the one value that travels: the session keeps it in its open round, a runtime hands it to the harness to run (Harness.RunCall) and gets it back, and Commit applies it once the round is complete.
A run ends in one of three ways: the call has its result (Done), it parks on an interrupt the user answers (Park), or it waits on a job (Await). Body is the harness's own part; a runtime may keep it elsewhere between runs (in its session store, by Key), so what it keeps in its history stays small.
type CallBody ¶ added in v0.5.0
type CallBody struct {
// contains filtered or unexported fields
}
CallBody is the harness's part of a call: its result message and the window effect it asks for, its park, the OnCall layers it passed, and the shared state its runs wrote, in order. Only the harness reads it; a runtime moves it as JSON.
func (CallBody) MarshalJSON ¶ added in v0.5.0
MarshalJSON implements json.Marshaler.
func (*CallBody) Text ¶ added in v0.5.0
Text is the call's result text: what its tool-result event carried.
func (*CallBody) UnmarshalJSON ¶ added in v0.5.0
UnmarshalJSON implements json.Unmarshaler. A park of an interrupt type this process does not register fails it.
type CallContext ¶ added in v0.5.0
type CallContext struct {
// contains filtered or unexported fields
}
CallContext is what a tool call's tool gets: progress events, the session's user state, Park, and the session's Runtime jobs. Each call of a reply gets its own, so calls run at once without sharing state. A call reads its own writes first, then the committed state; it writes only here, and Commit applies its writes in call order. A tool may use it from goroutines. Only the harness makes one.
func (*CallContext) CancelJob ¶ added in v0.5.0
func (cc *CallContext) CancelJob(_ context.Context, id string) error
CancelJob stops one job of this session and drops it from Jobs.
func (*CallContext) CurrentToolCallID ¶ added in v0.5.0
func (cc *CallContext) CurrentToolCallID() string
CurrentToolCallID is this call's id. A runtime may run a call's step again when it did not record the step's result (a worker died), so a tool with external side effects (a write, a send, a charge) passes the id as its idempotency key.
func (*CallContext) EmitUpdate ¶ added in v0.5.0
func (cc *CallContext) EmitUpdate(message string)
EmitUpdate sends a non-blocking progress update for the call.
func (*CallContext) Jobs ¶ added in v0.5.0
func (cc *CallContext) Jobs() []Job
Jobs is the session's running children and the ones this call started (a call records a start only for a child that is not running yet). Waiting specialist children appear as running.
func (*CallContext) Park ¶ added in v0.5.0
func (cc *CallContext) Park(intr Interrupt) (Interrupt, error)
Park parks the call on intr and returns it as the error the tool propagates. The call's run after resume gets the answered interrupt of intr's type and a nil error. intr's type must be registered (RegisterInterrupt), so a parked call can be read back.
func (*CallContext) Schedule ¶ added in v0.5.0
func (cc *CallContext) Schedule(_ context.Context, job JobRequest) (Job, error)
Schedule starts a job of this session: a Runtime job worker (a shell pipeline, a long data job). Specialists are not scheduled by tools: the model starts them with spawn_specialist. With JobRequest.Wait the call waits and the job's output is its result; otherwise the output arrives later as an inbox message. Pass the id to Jobs or CancelJob.
func (*CallContext) StateDelete ¶ added in v0.5.0
func (cc *CallContext) StateDelete(key string)
StateDelete records a delete of key on the call; Commit applies it.
type CommitIn ¶ added in v0.5.0
type CommitIn struct {
State map[string]any `json:"state,omitempty"`
Round *Round `json:"round,omitempty"`
Users []*message.Message `json:"users,omitempty"`
// Collapse collapses the window into a summary after the rest: the
// provider refused the last request as over the context window.
Collapse bool `json:"collapse,omitempty"`
}
CommitIn is what one Commit writes, in this order: host state, a round (its calls' state writes in call order), then user messages, each a round of its own.
type Harness ¶ added in v0.5.0
type Harness struct {
// contains filtered or unexported fields
}
Harness is one session's harness for one step: a model request, one tool call, or a commit to the window. Durable runtimes construct it for each step; hosts use session.Client.
func NewHarness ¶ added in v0.5.0
func NewHarness(ctx context.Context, opts AgentOptions) (*Harness, error)
NewHarness builds a Harness for one turn slice. Session runtimes call this after BindTurn. Hosts use a session.Client.
func (*Harness) Checkpoint ¶ added in v0.5.0
func (a *Harness) Checkpoint() ([]session.CheckpointEntry, error)
Checkpoint is the session's committed state as rows: the window of complete rounds, the plan, user state, permission decisions and search rests. A round in progress is not in it. A runtime stores the rows (session.Store) and diffs them against the last ones it saved, so a commit writes only what changed; only the harness reads their values.
func (*Harness) Close ¶ added in v0.5.0
func (a *Harness) Close()
Close releases the turn's MCP connections. The session runtime closes the MountSession. Call after the events channel is drained, or when construct fails.
func (*Harness) Commit ¶ added in v0.5.0
Commit is the Commit step: it applies in to the committed state (host state, then a round: each call's state writes in call order, then the round's messages; then each user message as a round of its own). A call of the round without its result is cancelled. The runtime saves the session after it; it is the only step whose state is saved.
func (*Harness) Infer ¶ added in v0.5.0
Infer is the Infer step: one model request on the committed window. It changes no session state: the reply commits as a round once its calls have their results.
func (*Harness) RestoreCheckpoint ¶ added in v0.5.0
func (a *Harness) RestoreCheckpoint(rows []session.CheckpointEntry) error
RestoreCheckpoint replaces the session's durable state with the rows'.
func (*Harness) RunCall ¶ added in v0.5.0
RunCall is the Tool step: it runs c once, from what its earlier runs did (its Body), and returns it changed. A job's result becomes the call's result; an answer resumes its park; otherwise its tool runs. It changes no session state: the call's body carries its writes for Commit.
type Interrupt ¶
type Interrupt interface {
// TypeName returns a stable, unique name for this interrupt type. It is
// used as the JSON discriminator when persisting interrupts to session
// storage and as the lookup key in the interrupt registry.
TypeName() string
// Serialize the interrupt to a byte slice for transmission.
Serialize() ([]byte, error)
// Return the interrupt to the agent workflow with a serialized
// payload of the interrupt result.
Return([]byte) error
// Error makes Interrupt compatible with the error interface.
Error() string
}
Interrupt represents a pending interrupt in an agent workflow requesting the user for additional input or approval. Implementations must also satisfy the error interface so they can be returned from tool handlers and detected via errors.As.
func NewInterrupt ¶ added in v0.4.0
NewInterrupt returns a fresh Interrupt for a registered type name.
func ToolPermissionOnCall ¶ added in v0.2.0
func ToolPermissionOnCall(inv ToolInvocation) Interrupt
ToolPermissionOnCall parks a tool_permission interrupt before the handler. The permission store's allow-always and reject-always answer it without a park.
type Job ¶ added in v0.3.3
Job is one background job of the current session as tools may see it. State is running, completed, or failed. A specialist child waiting for input stays running. Name is the specialist or registered worker.
type JobRequest ¶ added in v0.3.3
type JobRequest struct {
Name string
Task string
// Wait makes the call wait for the job: the job's output is the call's
// result. Without it the call goes on, and the output arrives later as
// an inbox message.
Wait bool
}
JobRequest is Schedule input. Name is a Runtime job worker.
type JobStart ¶ added in v0.5.0
type JobStart struct {
ID string `json:"id"`
Name string `json:"name"`
Task string `json:"task"`
// Specialist is a nested session; otherwise a named worker.
Specialist bool `json:"specialist,omitempty"`
}
JobStart is a child a tool call asks the runtime to start. The runtime starts and cancels children from the call's outcome.
type LLMResponseChunk ¶
type LLMResponseChunk struct {
TurnId string
MessageId string
ToolCalls []message.ToolCall
Type session.EventType
Content string
IsComplete bool
// Error is set on terminal provider failures (Type == session.EventError).
// Harness copies it onto session.Event.Error so protocols can errors.Is
// stop-reason sentinels (refusal, max_tokens, …).
Error error
// Token usage when the provider reports it (typically on session.EventComplete
// after response.completed). Zero means unknown / not reported.
InputTokens int
OutputTokens int
ReasoningTokens int
CachedTokens int
CacheWriteTokens int
// EncryptedContent is the provider's opaque data for a reasoning item,
// which only the provider client reads. It is copied onto the Message so
// a later request can replay the item without provider-side storage.
EncryptedContent string
}
LLMResponseChunk is the streaming unit emitted by a Model's Invoke call. Provider parse only — not client-facing wire.
func (LLMResponseChunk) Err ¶ added in v0.5.0
func (c LLMResponseChunk) Err() error
Err is the chunk's failure: its Error, or for an error chunk without one, its Content; nil for any other chunk.
type Model ¶ added in v0.5.0
type Model interface {
Invoke(ctx context.Context, req ModelRequest) (chan LLMResponseChunk, error)
// CountTokens counts what Invoke would send for req, with the provider.
// A provider that cannot count returns an error that wraps
// ErrCannotCount. Invoke reports a request the provider refused as over
// the context window with session.ErrContextLength.
CountTokens(ctx context.Context, req ModelRequest) (int, error)
MaxContextWindow() (int, error)
// ModelTelemetryIdentity names the provider and model for model spans.
ModelTelemetryIdentity() telemetry.ModelIdentity
// SupportsMIME reports whether the currently selected model accepts the
// given MIME type as user input. Empty and text/* are always true.
// Probe representatives for ads (e.g. image/png); do not enumerate all types.
SupportsMIME(mimeType string) bool
}
Model is the model provider interface used by the harness. Model and endpoint settings (the fluent With* builders) live on concrete providers such as *openai.Model; everything per request is in ModelRequest.
type ModelRequest ¶ added in v0.5.0
type ModelRequest struct {
Messages []*message.Message
Tools []*Tool
SystemPrompt string
// CacheKey is the session id. A strategy may send it so the provider
// keeps the session's prompt prefix cached.
CacheKey string
}
ModelRequest is one model request. A strategy holds no per-request state: everything a request needs is here, so one strategy is safe to share across sessions and calls.
type OnCallFunc ¶ added in v0.2.0
type OnCallFunc func(ToolInvocation) Interrupt
OnCallFunc builds a check that runs before the handler and may park the call. Return nil to skip it.
type Overflow ¶ added in v0.5.0
type Overflow interface {
// Keep stores text, the full result of the session's call callID, and
// returns where the agent reads it.
Keep(ctx context.Context, sessionID, callID, text string) (string, error)
}
Overflow keeps the full text of results trimmed from the window, where the agent can read it again. Package workspace keeps it on the workspace.
type Park ¶ added in v0.5.0
Park is a call's interrupt as the client sees it. InterruptID is the call id; Resume answers it by that id.
type PermissionOption ¶
type PermissionOption struct {
OptionID string `json:"optionId"`
Name string `json:"name"`
Kind string `json:"kind"`
}
PermissionOption is a single choice offered when a tool requires user approval. Field names match ACP session/request_permission options.
func DefaultPermissionOptions ¶
func DefaultPermissionOptions() []PermissionOption
DefaultPermissionOptions are the standard ACP permission choices.
type Reply ¶ added in v0.5.0
type Reply struct {
Messages []*message.Message `json:"messages"`
Calls []message.ToolCall `json:"calls,omitempty"`
Result string `json:"result,omitempty"`
// Timeouts are each call's tool timeout (ToolConfig.Timeout), by call
// index; zero is none. A runtime bounds the call's step by it.
Timeouts []time.Duration `json:"timeouts,omitempty"`
// InputTokens is the provider's count of the request, on the window
// the reply's round commits to; zero when it reported none. The
// round's Commit gives it to the window, which sizes the next
// requests from it.
InputTokens int `json:"inputTokens,omitempty"`
}
Reply is one model reply: its messages (text, reasoning, and the message that carries its calls) and its calls. A reply without calls is complete, and Result is its text.
type Round ¶ added in v0.5.0
Round is a reply and its calls, in call order. A round commits when each call has its result; a call without one then is cancelled.
type Specialist ¶ added in v0.2.0
type Specialist struct {
Tools []*Tool
Instructions string
Model Model
Name string
Description string
// Specialists are nested workers available to this worker when it runs.
Specialists []*Specialist
}
Specialist describes a nested session a harness can spawn via spawn_specialist. Specs may nest via Specialists. Child sessions inherit the parent world through AgentOptions.WithSpecialist (VFS, brain, MCP, interceptors). Spec fields replace model, instructions, tools, and nested Specialists. They skip planningWriteLock.
func FindSpecialist ¶ added in v0.2.0
func FindSpecialist(specs []*Specialist, name string) *Specialist
FindSpecialist returns the named worker from specs, including nested Specialists.
type Todo ¶
type Todo struct {
Title string `json:"title" desc:"Todo title. Must be unique in the list."`
Status TodoStatus `json:"status" desc:"pending, in_progress, or completed."`
Description string `json:"description" desc:"Objective, expected outcomes, and acceptance criteria."`
}
Todo is one item in an agent plan list (create_plan / plan_update stream data).
type TodoStatus ¶ added in v0.2.0
type TodoStatus string
const ( TodoStatusPending TodoStatus = "pending" TodoStatusCompleted TodoStatus = "completed" TodoStatusInProgress TodoStatus = "in_progress" )
type Tool ¶
type Tool struct {
// contains filtered or unexported fields
}
Tool is a registered harness tool. Construct with NewTool(ToolConfig{...}). Fields are unexported; hosts read metadata through the getters below.
func NewTool ¶
func NewTool(cfg ToolConfig) *Tool
func (*Tool) Description ¶
Description tells the model what the tool does.
func (*Tool) Parameters ¶ added in v0.5.0
Parameters is the JSON Schema of the tool's arguments. It is never nil.
func (*Tool) QualifiedName ¶ added in v0.5.0
QualifiedName is the name the model calls the tool by: namespace__name for a namespaced tool, else its name.
type ToolAccess ¶ added in v0.2.0
type ToolAccess uint8
ToolAccess is an immutable permission bitmask. Zero allows nothing.
const ( ToolReadAccess ToolAccess = ToolAccess(ReadPermission) ToolWriteAccess ToolAccess = ToolAccess(WritePermission) ToolReadWriteAccess ToolAccess = ToolAccess(ReadPermission | WritePermission) ToolExecuteAccess ToolAccess = ToolAccess(ExecutePermission) ToolReadExecuteAccess ToolAccess = ToolAccess(ReadPermission | ExecutePermission) ToolFullAccess ToolAccess = ToolAccess(ReadPermission | WritePermission | ExecutePermission) )
func (ToolAccess) Allows ¶ added in v0.2.0
func (a ToolAccess) Allows(p ToolPermission) bool
Allows reports whether a includes p.
type ToolCallFunc ¶
type ToolCallFunc func(ctx context.Context, inv ToolInvocation) (ToolOutcome, error)
ToolCallFunc is the next interceptor step or the final tool invoke. It returns the call's outcome: the model-visible output and its window effect.
type ToolConfig ¶
type ToolConfig struct {
Name string
Description string
DisplayName string
Namespace string
Category message.ToolCategory
Access ToolAccess
Timeout time.Duration
// OnCall is the pre-invoke middleware stack. Each constructor may park.
// Return nil from a constructor to skip that layer. Types must be registered.
OnCall []OnCallFunc
// Handler is a Go function. Close over clients in the constructor that calls NewTool.
// Optional parameters: context.Context, an args struct, CallContext.
Handler any
}
type ToolHandlerFunc ¶
type ToolInterceptor ¶
type ToolInterceptor func(ctx context.Context, inv ToolInvocation, next ToolCallFunc) (ToolOutcome, error)
ToolInterceptor wraps a tool call. Call next to continue, or return early to short-circuit. An interceptor may change the outcome next returns: its Output replaces what the model sees, and its Effect changes the window when the call's round commits. Host interceptors on AgentOptions wrap outside the built-in planning lock and OnCall middleware; they never replace that chain.
type ToolInvocation ¶
type ToolInvocation struct {
Tool *Tool
ArgsJSON string
CallContext *CallContext
}
ToolInvocation is one tool call in the interceptor chain.
type ToolOutcome ¶ added in v0.2.0
type ToolOutcome struct {
Output string
// Effect applies once, when the call's round commits.
Effect ToolResultEffect
}
ToolOutcome is a call's result: the model-visible output and the window effect it asks for. A handler may return it (the plan tools do); an interceptor may change it after next returns.
type ToolPermission ¶
type ToolPermission uint8
const ( ReadPermission ToolPermission = 1 << iota WritePermission ExecutePermission )
type ToolPermissionInterrupt ¶
type ToolPermissionInterrupt struct {
ToolName string `json:"toolName,omitempty"`
Title string `json:"title,omitempty"` // human-readable invocation label
Options []PermissionOption `json:"options"`
// Set by Return after the consumer selects an option. The checkpoint
// keeps them on the call's park, so the call's run after resume sees the
// decision. Serialize omits them so the client park payload stays
// unanswered.
SelectedOptionID string `json:"selectedOptionId,omitempty"`
SelectedKind string `json:"selectedKind,omitempty"`
Allowed bool `json:"allowed,omitempty"`
}
ToolPermissionInterrupt asks the user to approve or reject a tool call.
func (*ToolPermissionInterrupt) Error ¶ added in v0.4.0
func (p *ToolPermissionInterrupt) Error() string
func (*ToolPermissionInterrupt) Return ¶ added in v0.4.0
func (p *ToolPermissionInterrupt) Return(payload []byte) error
func (*ToolPermissionInterrupt) Serialize ¶ added in v0.4.0
func (p *ToolPermissionInterrupt) Serialize() ([]byte, error)
func (*ToolPermissionInterrupt) TypeName ¶ added in v0.4.0
func (p *ToolPermissionInterrupt) TypeName() string
type ToolPermissionPayload ¶ added in v0.4.0
type ToolPermissionPayload struct {
InterruptId string `json:"interruptId,omitempty"`
OptionID string `json:"optionId"`
}
ToolPermissionPayload is the consumer resolution for a tool permission interrupt.
type ToolResultEffect ¶
type ToolResultEffect int
ToolResultEffect changes the window when the round of the call that asked for it commits. Higher values win when a round asks for two.
const ( EffectNone ToolResultEffect = iota // EffectHandoff rebuilds the window for the next open todos. EffectHandoff // EffectInstallPlanDocument sets the window to [user, plan document]. EffectInstallPlanDocument )
type UserChoice ¶
type UserSelectionInterrupt ¶
type UserSelectionInterrupt struct {
Question string `json:"question,omitempty"`
Options []UserChoice `json:"options"`
ConfirmedChoice *UserChoice
}
func (*UserSelectionInterrupt) Error ¶ added in v0.4.0
func (c *UserSelectionInterrupt) Error() string
func (*UserSelectionInterrupt) Return ¶ added in v0.4.0
func (c *UserSelectionInterrupt) Return(payload []byte) error
func (*UserSelectionInterrupt) Serialize ¶ added in v0.4.0
func (c *UserSelectionInterrupt) Serialize() ([]byte, error)
func (*UserSelectionInterrupt) TypeName ¶ added in v0.4.0
func (c *UserSelectionInterrupt) TypeName() string
type UserSelectionPayload ¶ added in v0.4.0
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package anthropic is the tacklr.Model for Claude models on the Claude API (the Messages API).
|
Package anthropic is the tacklr.Model for Claude models on the Claude API (the Messages API). |
|
Package brain is Tacklr's knowledge-base retrieval engine.
|
Package brain is Tacklr's knowledge-base retrieval engine. |
|
graphtest
Package graphtest is the contract every brain graph backend must meet.
|
Package graphtest is the contract every brain graph backend must meet. |
|
helixgraph
Package helixgraph is a brain.Graph on HelixDB.
|
Package helixgraph is a brain.Graph on HelixDB. |
|
postgres
Package postgres is the optional Postgres implementation of brain.Store.
|
Package postgres is the optional Postgres implementation of brain.Store. |
|
storetest
Package storetest is the contract every brain store must meet.
|
Package storetest is the contract every brain store must meet. |
|
examples
|
|
|
cloudflare
command
Command cloudflare is an example Worker that runs Tacklr sessions as Durable Objects, and serves ACP over WebSocket from a connection object for each socket.
|
Command cloudflare is an example Worker that runs Tacklr sessions as Durable Objects, and serves ACP over WebSocket from a connection object for each socket. |
|
host
Package host is the examples' protocol server: ACP over WebSocket on a session client, behind one bearer token.
|
Package host is the examples' protocol server: ACP over WebSocket on a session client, behind one bearer token. |
|
temporal/agent
Package agent is the agent the example's workers run: its tools, its specialist and its workspace.
|
Package agent is the agent the example's workers run: its tools, its specialist and its workspace. |
|
temporal/cmd/host
command
Command host is the example's protocol server: ACP over WebSocket on the Temporal session client.
|
Command host is the example's protocol server: ACP over WebSocket on the Temporal session client. |
|
temporal/cmd/internal/stack
Package stack opens what the example's two programs share, from the environment: the Temporal connection, the Postgres pool and the session stores on it, the model client, and the key of the workers' live endpoints.
|
Package stack opens what the example's two programs share, from the environment: the Temporal connection, the Postgres pool and the session stores on it, the model client, and the key of the workers' live endpoints. |
|
temporal/cmd/worker
command
Command worker runs the example's sessions: the session workflow and its steps, the agent and its workspace, and the live endpoint that streams a session's deltas to the hosts.
|
Command worker runs the example's sessions: the session workflow and its steps, the agent and its workspace, and the live endpoint that streams a session's deltas to the hosts. |
|
internal
|
|
|
acptest
Package acptest drives ACP in tests as an editor does: a session client and agent, a server on a real HTTP listener, and a client on a WebSocket that reads the frames in order and answers the agent's requests.
|
Package acptest drives ACP in tests as an editor does: a session client and agent, a server on a real HTTP listener, and a client on a WebSocket that reads the frames in order and answers the agent's requests. |
|
faultproxy
Package faultproxy is an HTTP proxy that live tests put in front of a backend (a container such as Helix, an S3 server or Azurite) to fail its traffic at the network.
|
Package faultproxy is an HTTP proxy that live tests put in front of a backend (a container such as Helix, an S3 server or Azurite) to fail its traffic at the network. |
|
google
Package google holds what is Google-specific in the REST calls the vfs adapters make: the multipart upload.
|
Package google holds what is Google-specific in the REST calls the vfs adapters make: the multipart upload. |
|
google/docs
Package docs is the Docs v1 JSON the vfs adapter reads and writes.
|
Package docs is the Docs v1 JSON the vfs adapter reads and writes. |
|
google/drive
Package drive is the Drive v3 JSON the vfs adapter reads and writes.
|
Package drive is the Drive v3 JSON the vfs adapter reads and writes. |
|
google/sheets
Package sheets is the Sheets v4 JSON the vfs adapter reads and writes.
|
Package sheets is the Sheets v4 JSON the vfs adapter reads and writes. |
|
helixtest
Package helixtest runs the Helix server live tests use, and one graph opened on it.
|
Package helixtest runs the Helix server live tests use, and one graph opened on it. |
|
livesess
Package livesess runs the session runtime on the live stack for tests: a Temporal worker on the shared Temporal server, over the Postgres session stores.
|
Package livesess runs the session runtime on the live stack for tests: a Temporal worker on the shared Temporal server, over the Postgres session stores. |
|
pgtest
Package pgtest runs the Postgres that live tests share: one pgvector container per test binary (Ryuk reaps it on exit), with the extensions the brain store uses installed in public, and a schema per test.
|
Package pgtest runs the Postgres that live tests share: one pgvector container per test binary (Ryuk reaps it on exit), with the extensions the brain store uses installed in public, and a schema per test. |
|
pgtrace
Package pgtrace is the one Postgres tracer of Tacklr's stores: a span for each statement under its caller's context (otelpgx), named by the statement and without the pool's connection acquires.
|
Package pgtrace is the one Postgres tracer of Tacklr's stores: a span for each statement under its caller's context (otelpgx), named by the statement and without the pool's connection acquires. |
|
provider
Package provider holds what the model clients share and no provider's rules: the HTTP request, the server-sent event reader, the stream of response chunks, the error of an HTTP failure, and its telemetry.
|
Package provider holds what the model clients share and no provider's rules: the HTTP request, the server-sent event reader, the stream of response chunks, the error of an HTTP failure, and its telemetry. |
|
rest
Package rest calls the JSON REST APIs the vfs adapters use (Google Drive, Docs and Sheets; Microsoft Graph) over net/http and encoding/json.
|
Package rest calls the JSON REST APIs the vfs adapters use (Google Drive, Docs and Sheets; Microsoft Graph) over net/http and encoding/json. |
|
s3test
Package s3test runs the S3-compatible server live tests share.
|
Package s3test runs the S3-compatible server live tests share. |
|
temporaldocker
Package temporaldocker starts the same Temporal server the live tests use: Postgres and temporalio/server in Docker.
|
Package temporaldocker starts the same Temporal server the live tests use: Postgres and temporalio/server in Docker. |
|
testdrive
Package testdrive is an internal httptest fixture for Drive, Docs, and Sheets.
|
Package testdrive is an internal httptest fixture for Drive, Docs, and Sheets. |
|
testgit
Package testgit runs an in-process git host for one bare repository: smart HTTP (git http-backend over net/http/cgi) behind a basic-auth token, and SSH (git upload-pack / receive-pack) behind one deploy key.
|
Package testgit runs an in-process git host for one bare repository: smart HTTP (git http-backend over net/http/cgi) behind a basic-auth token, and SSH (git upload-pack / receive-pack) behind one deploy key. |
|
testkit
Package testkit provides shared test doubles for harness and server integration tests.
|
Package testkit provides shared test doubles for harness and server integration tests. |
|
Package mcp connects a harness to MCP servers with the official MCP Go SDK.
|
Package mcp connects a harness to MCP servers with the official MCP Go SDK. |
|
Package message is the conversation data hosts, models and the harness exchange: messages, their content parts, and tool calls.
|
Package message is the conversation data hosts, models and the harness exchange: messages, their content parts, and tool calls. |
|
Package server serves a session.Client over host-defined wire protocols.
|
Package server serves a session.Client over host-defined wire protocols. |
|
acp
Package acp is the Agent Client Protocol built into the server.
|
Package acp is the Agent Client Protocol built into the server. |
|
postgres
Package postgres keeps protocol wire envelopes in Postgres: the server.ProtocolWireStore a protocol reads on session/load.
|
Package postgres keeps protocol wire envelopes in Postgres: the server.ProtocolWireStore a protocol reads on session/load. |
|
durableobject
Package durableobject runs Tacklr sessions as durable objects: one object per session, each with its own ordered storage, alarm and address, as a Cloudflare Durable Object has.
|
Package durableobject runs Tacklr sessions as durable objects: one object per session, each with its own ordered storage, alarm and address, as a Cloudflare Durable Object has. |
|
durableobject/cloudflare
Package cloudflare runs Tacklr sessions on Cloudflare Workers: each session is a SQLite-backed Durable Object that runs a durableobject.Object, and the Worker serves the host's own routes over a session.Client of those objects.
|
Package cloudflare runs Tacklr sessions on Cloudflare Workers: each session is a SQLite-backed Durable Object that runs a durableobject.Object, and the Worker serves the host's own routes over a session.Client of those objects. |
|
durableobject/dotest
Package dotest runs durable object sessions in memory, for tests: a host's tests of its agent on the durable object runtime, and the runtime's own.
|
Package dotest runs durable object sessions in memory, for tests: a host's tests of its agent on the durable object runtime, and the runtime's own. |
|
durableobject/internal/inproc
Package inproc serves an http.Handler in this process, without a network: the response streams through a pipe as the handler writes it.
|
Package inproc serves an http.Handler in this process, without a network: the response streams through a pipe as the handler writes it. |
|
internal
Package adapter holds what the session runtimes share: a turn's auth on the session's mount recipes, tool outcomes kept by call key, and host state encoding.
|
Package adapter holds what the session runtimes share: a turn's auth on the session's mount recipes, tool outcomes kept by call key, and host state encoding. |
|
orchestrator
Package orchestrator decides each step of a session, the same way on every runtime.
|
Package orchestrator decides each step of a session, the same way on every runtime. |
|
postgres
Package postgres keeps sessions durable in Postgres: the session Store (checkpoints and tool-call bodies), SecretStorage (the users' delegated tokens, sealed before they are written) and the EventLog.
|
Package postgres keeps sessions durable in Postgres: the session Store (checkpoints and tool-call bodies), SecretStorage (the users' delegated tokens, sealed before they are written) and the EventLog. |
|
storetest
Package storetest is the contract every session Store, SecretStorage and EventLog must meet.
|
Package storetest is the contract every session Store, SecretStorage and EventLog must meet. |
|
temporal
Package temporal is the client side of the Temporal runtime: Client implements session.Client with one Temporal workflow per session.
|
Package temporal is the client side of the Temporal runtime: Client implements session.Client with one Temporal workflow per session. |
|
temporal/internal/protocol
Package protocol is how a Temporal client and worker talk about one session: the workflow's type name and input, its signal and query names, and the item its event stream carries.
|
Package protocol is how a Temporal client and worker talk about one session: the workflow's type name and input, its signal and query names, and the item its event stream carries. |
|
temporal/worker
Package worker runs tacklr sessions on Temporal: it registers the session workflow and its turn activities, and keeps each session's harness (VFS, MCP connections, tools) between steps.
|
Package worker runs tacklr sessions on Temporal: it registers the session workflow and its turn activities, and keeps each session's harness (VFS, MCP connections, tools) between steps. |
|
Package shell is the run_command tool: a shell jailed to one session's workspace as the host shows it on disk (package vfs/fuse).
|
Package shell is the run_command tool: a shell jailed to one session's workspace as the host shows it on disk (package vfs/fuse). |
|
Package skills discovers and parses application-owned SKILL.md files: one skill per directory, each with a SKILL.md.
|
Package skills discovers and parses application-owned SKILL.md files: one skill per directory, each with a SKILL.md. |
|
Package telemetry is Tacklr's OpenTelemetry instrumentation: spans, metrics and log events on the process-wide OpenTelemetry providers, and the Carrier that takes a turn's trace across what a context cannot (a wake, a durable step, a journal, an HTTP request).
|
Package telemetry is Tacklr's OpenTelemetry instrumentation: spans, metrics and log events on the process-wide OpenTelemetry providers, and the Carrier that takes a turn's trace across what a context cannot (a wake, a durable step, a journal, an HTTP request). |
|
export
Package export installs the OpenTelemetry SDK providers a Tacklr host process sends its telemetry to: OTLP traces, metrics and logs (Init), or a Prometheus scrape (PrometheusMeterProvider).
|
Package export installs the OpenTelemetry SDK providers a Tacklr host process sends its telemetry to: OTLP traces, metrics and logs (Init), or a Prometheus scrape (PrometheusMeterProvider). |
|
otlpjson
Package otlpjson sends spans to an OTLP/HTTP endpoint in OTLP's JSON encoding (POST {endpoint}/v1/traces, application/json), over net/http alone.
|
Package otlpjson sends spans to an OTLP/HTTP endpoint in OTLP's JSON encoding (POST {endpoint}/v1/traces, application/json), over net/http alone. |
|
Package vfs is Tacklr's virtual filesystem: session mounts, path I/O, and content IR.
|
Package vfs is Tacklr's virtual filesystem: session mounts, path I/O, and content IR. |
|
adapters
Package adapters contains source-format codecs for rich text documents.
|
Package adapters contains source-format codecs for rich text documents. |
|
awss3
Package awss3 connects the vfs S3 provider to the AWS SDK v2 S3 client:
|
Package awss3 connects the vfs S3 provider to the AWS SDK v2 S3 client: |
|
azureblob
Package azureblob connects the vfs Blob provider to the Azure Blob SDK:
|
Package azureblob connects the vfs Blob provider to the Azure Blob SDK: |
|
fuse
Package fuse shows a vfs.MountSession as a directory on the host kernel, so host processes (run_command) see the session's virtual tree.
|
Package fuse shows a vfs.MountSession as a directory on the host kernel, so host processes (run_command) see the session's virtual tree. |
|
internal/httprange
Package httprange is the HTTP Range handling the vfs SDK adapters share: n bytes from off, where n < 0 reads to the end and n is never 0.
|
Package httprange is the HTTP Range handling the vfs SDK adapters share: n bytes from off, where n < 0 reads to the end and n is never 0. |
|
internal/vfstest
Package vfstest is the contract every built-in vfs backend must meet.
|
Package vfstest is the contract every built-in vfs backend must meet. |
|
mount
Package mount is how a host names a cloud folder for a session to mount: the binding, its credential, and the parameter names providers read.
|
Package mount is how a host names a cloud folder for a session to mount: the binding, its credential, and the parameter names providers read. |
|
Package vfsindex bridges a vfs.MountSession into brain knowledge objects.
|
Package vfsindex bridges a vfs.MountSession into brain knowledge objects. |
|
Package workspace is the agent's /workspace on a turn: the tree of mounts the host chose (package vfs), and what the harness gets from it.
|
Package workspace is the agent's /workspace on a turn: the tree of mounts the host chose (package vfs), and what the harness gets from it. |