Documentation
¶
Index ¶
- func Load(ctx context.Context, agentSource config.Source, ...) (*team.Team, error)
- func ToolsetIdentity(t latest.Toolset) string
- func ToolsetSignature(t latest.Toolset) string
- func WithInstructions(inner tools.ToolSet, instruction string) tools.ToolSet
- func WithModelOverride(inner tools.ToolSet, model string) tools.ToolSet
- func WithNoToolsFilter(inner tools.ToolSet) tools.ToolSet
- func WithReadOnlyFilter(inner tools.ToolSet, readOnly bool) tools.ToolSet
- func WithToolsExcludeFilter(inner tools.ToolSet, toolNames ...string) tools.ToolSet
- func WithToolsFilter(inner tools.ToolSet, toolNames ...string) tools.ToolSet
- type DeferredToolSet
- type Expander
- type LoadResult
- type Opt
- func WithCodeMode(wrap func(toolSets ...tools.ToolSet) tools.ToolSet) Opt
- func WithDeferredTools[D DeferredToolSet](newDeferred func() D) Opt
- func WithExpander[E Expander](newExpander func(environment.Provider) E) Opt
- func WithModelOptions(opts ...options.Opt) Opt
- func WithModelOverrides(overrides []string) Opt
- func WithPromptFiles(files []string) Opt
- func WithProviderRegistry(registry *provider.Registry) Opt
- func WithSourceResolver(resolver SourceResolver) Opt
- func WithStrict(features ...config.Feature) Opt
- func WithToolsetRegistry(registry ToolsetRegistry) Opt
- func WithToon(wrap func(inner tools.ToolSet, spec string) tools.ToolSet) Opt
- func WithWorkingDir(dir string) Opt
- type SourceResolver
- type ToolsetChange
- type ToolsetCreator
- type ToolsetDiff
- type ToolsetRegistry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
func Load(ctx context.Context, agentSource config.Source, runConfig *config.RuntimeConfig, opts ...Opt) (*team.Team, error)
Load loads an agent team from the given source
func ToolsetIdentity ¶ added in v1.54.0
ToolsetIdentity returns a stable string that identifies a toolset across reloads. Named toolsets (the common case for MCP/LSP) are keyed by Type+Name. Toolsets without a name fall back to a key derived from their type and connection target.
The function is deterministic and total: every Toolset has a unique non-empty identity even when several share the same config (the fallback includes the JSON signature to break ties).
func ToolsetSignature ¶ added in v1.54.0
ToolsetSignature returns a hex-encoded SHA-256 of the canonical JSON representation of t. Two toolsets with byte-identical signatures are considered configuration-identical for hot-reload purposes.
Any field present in latest.Toolset participates in the signature, so adding new fields automatically participates in change detection without further wiring.
func WithInstructions ¶
func WithModelOverride ¶ added in v1.30.1
WithModelOverride wraps a toolset so that every tool it produces carries the given model in its ModelOverride field, enabling per-toolset model routing.
func WithNoToolsFilter ¶ added in v1.111.0
WithNoToolsFilter creates a toolset that exposes no tools but preserves all other capabilities (like Instructions) of the inner toolset.
func WithReadOnlyFilter ¶ added in v1.87.0
WithReadOnlyFilter wraps a toolset so it only lists and exposes tools whose annotations carry a read-only hint. Every other tool is filtered out, so the agent can never call a mutating tool from this toolset. When readOnly is false the inner toolset is returned unchanged.
func WithToolsExcludeFilter ¶
WithToolsExcludeFilter creates a toolset that excludes the specified tools. If no tool names are provided, all tools are included.
Types ¶
type DeferredToolSet ¶ added in v1.132.0
type DeferredToolSet interface {
tools.ToolSet
AddSource(toolset tools.ToolSet, deferAll bool, toolNames []string)
HasSources() bool
}
DeferredToolSet collects tools declared with `defer` so the model discovers and activates them on demand; pkg/tools/builtin/deferred implements it.
type Expander ¶ added in v1.132.0
type Expander interface {
Expand(ctx context.Context, text string, values map[string]string) string
ExpandCommands(ctx context.Context, cmds types.Commands) types.Commands
}
Expander expands ${...} expressions in agent text: instructions, descriptions, welcome messages, toolset instructions and slash commands. The default only substitutes ${env.NAME} references and bound values; pkg/js provides the full JavaScript evaluator (see WithExpander).
type LoadResult ¶
type LoadResult struct {
Team *team.Team
Models map[string]latest.ModelConfig
Providers map[string]latest.ProviderConfig
// ProviderRegistry is the registry used to instantiate model providers for this load.
ProviderRegistry *provider.Registry
// AgentDefaultModels maps agent names to their configured default model references
AgentDefaultModels map[string]string
// Budget is the manifest's run-wide budget, or nil when the manifest
// sets no run-wide ceiling. It is per-run rather than per-agent, so it
// lives on the load result next to the team rather than on any
// individual agent.
Budget *latest.BudgetConfig
// Budgets are the manifest's named budget definitions, and
// AgentBudgets maps each agent to the budget names it declared. A name
// referenced by several agents is one shared pot.
Budgets map[string]latest.BudgetConfig
AgentBudgets map[string][]string
// EncryptedConfig is the encrypted agent config in effect for this load:
// either the explicit --encrypted-config / env value, or the one captured
// from the X-Cagent-Encrypted-Config response header when the agent YAML
// was fetched from a trusted Docker URL. Empty when neither applies.
EncryptedConfig string
}
LoadResult contains the result of loading an agent team, including the team and configuration needed for runtime model switching.
func LoadWithConfig ¶
func LoadWithConfig(ctx context.Context, agentSource config.Source, runConfig *config.RuntimeConfig, opts ...Opt) (result *LoadResult, err error)
LoadWithConfig loads an agent team and returns both the team and config info needed for runtime model switching.
type Opt ¶
type Opt func(*loadOptions) error
func WithCodeMode ¶ added in v1.132.0
WithCodeMode enables `code_mode_tools` (and RuntimeConfig.GlobalCodeMode): wrap is applied to an agent's toolsets so the model calls them from a single JavaScript tool. Pass codemode.Wrap from pkg/tools/codemode. Without it, configs asking for code mode fail to load.
func WithDeferredTools ¶ added in v1.132.0
func WithDeferredTools[D DeferredToolSet](newDeferred func() D) Opt
WithDeferredTools enables the `defer` toolset field. Pass deferred.New from pkg/tools/builtin/deferred. Without it, configs using `defer` fail to load.
func WithExpander ¶ added in v1.132.0
func WithExpander[E Expander](newExpander func(environment.Provider) E) Opt
WithExpander replaces the default ${...} expander with one built from the runtime environment when the team is loaded. Pass js.NewJsExpander to enable JavaScript expressions:
teamloader.WithExpander(js.NewJsExpander)
Slash commands additionally need the runtime evaluator; loaderdefaults.Opts registers it via jscommands.Register.
func WithModelOptions ¶ added in v1.103.0
WithModelOptions appends caller-supplied options.Opt values to every model client teamloader constructs for this load: primary, fallback, title, and compaction models, as well as models built while loading external (OCI/URL-referenced) sub-agents. Use this to thread cross-cutting model configuration — most notably options.WithHTTPTransportWrapper, which lets an embedder authenticate every outbound LLM request (regardless of provider) without depending on provider-specific environment variables or environment.IsTrustedDockerURL. The opts are appended after teamloader's own built-in opts (options.WithGateway, options.WithStructuredOutput, etc.), so they take precedence for any option that both sides set.
func WithModelOverrides ¶
func WithPromptFiles ¶
WithPromptFiles adds additional prompt files to all agents. These are merged with any prompt files defined in the agent config.
func WithProviderRegistry ¶ added in v1.84.0
WithProviderRegistry allows using a custom model provider registry instead of the default.
func WithSourceResolver ¶ added in v1.132.0
func WithSourceResolver(resolver SourceResolver) Opt
WithSourceResolver enables sub_agents, handoffs and force_handoff entries that reference agents outside the config (OCI references, URLs). Without it such references fail to load: teamloader deliberately has no default so embedders only link the source types they use.
func WithStrict ¶ added in v1.132.0
WithStrict rejects configs that rely on anything the application did not enable: a model provider missing from the provider registry, a toolset type missing from the toolset registry, or a config.Feature not listed here. Every unmet requirement is reported in one error before any model or toolset is built (see config.Requires). Without it, unknown toolset types are load-time warnings and unknown providers fail when their model is built. External agents loaded through config.FeatureExternalAgents are checked with the same rules.
func WithToolsetRegistry ¶
func WithToolsetRegistry(registry ToolsetRegistry) Opt
WithToolsetRegistry allows using a custom toolset registry instead of the default.
func WithToon ¶
WithToon enables the `toon` toolset field, which re-encodes matching tools' JSON output in the compact TOON format. Pass toon.Wrap from pkg/tools/toon. Without it, configs using `toon` fail to load.
func WithWorkingDir ¶ added in v1.104.0
WithWorkingDir overrides the working directory toolsets are built with, without touching the caller's RuntimeConfig. Callers that share one RuntimeConfig across concurrent loads (the API server, one per session) need this to keep each session's shell, filesystem and git tools rooted in that session's directory.
type SourceResolver ¶ added in v1.132.0
SourceResolver turns an external agent reference (OCI reference or URL) into a source. pkg/config/sources.Resolve is the full-featured implementation.
type ToolsetChange ¶ added in v1.54.0
ToolsetChange records a Toolset whose identity is unchanged but whose configuration signature differs.
type ToolsetCreator ¶
type ToolsetCreator func(ctx context.Context, toolset latest.Toolset, parentDir string, runConfig *config.RuntimeConfig, configName string) (tools.ToolSet, error)
ToolsetCreator is a function that creates a toolset based on the provided configuration. configName identifies the agent config file (e.g. "memory_agent" from "memory_agent.yaml").
func Creator ¶ added in v1.132.0
func Creator(create func() (tools.ToolSet, error)) ToolsetCreator
Creator adapts a toolset constructor that needs neither its YAML declaration nor the runtime config into a ToolsetCreator:
teamloader.NewToolsetRegistry(map[string]teamloader.ToolsetCreator{"think": teamloader.Creator(think.CreateToolSet)})
Packages whose constructors take more (shell, mcp, filesystem, ...) export a ready-made Creator instead.
func CreatorFromToolset ¶ added in v1.132.0
CreatorFromToolset adapts a constructor that only needs the YAML declaration (todo, model_picker, mcp_catalog) into a ToolsetCreator.
type ToolsetDiff ¶ added in v1.54.0
type ToolsetDiff struct {
Added []latest.Toolset
Removed []latest.Toolset
Changed []ToolsetChange
Unchanged []latest.Toolset
}
ToolsetDiff is the result of comparing two slices of latest.Toolset (typically the currently-running set and a freshly-loaded set from disk). It is a building block for hot-reload: the runtime can stop Removed toolsets, start Added ones, and stop+start Changed ones, while leaving Unchanged toolsets running.
Identity is established by ToolsetIdentity (name+type for named toolsets, falling back to type+command/url for the rare unnamed case). "Changed" is defined as identity-equal but Signature-different.
func DiffToolsets ¶ added in v1.54.0
func DiffToolsets(oldList, newList []latest.Toolset) ToolsetDiff
DiffToolsets compares two slices of toolset configs and returns a classification of which toolsets were added, removed, changed, or are unchanged.
The result preserves the order of the new slice for Added/Changed/ Unchanged, and the order of the old slice for Removed; this is a helpful invariant for status messages.
func (ToolsetDiff) HasChanges ¶ added in v1.54.0
func (d ToolsetDiff) HasChanges() bool
HasChanges reports whether the diff requires any runtime action. It is useful as a fast-path for the hot-reload trigger: if HasChanges is false, the runtime can skip the diff entirely.
type ToolsetRegistry ¶
type ToolsetRegistry interface {
CreateTool(ctx context.Context, toolset latest.Toolset, parentDir string, runConfig *config.RuntimeConfig, agentName string) (tools.ToolSet, error)
// Has reports whether a creator is registered for toolsetType.
Has(toolsetType string) bool
}
ToolsetRegistry manages the registration of toolset creators by type.
func NewDefaultToolsetRegistry ¶
func NewDefaultToolsetRegistry() ToolsetRegistry
NewDefaultToolsetRegistry returns the package-level default registry. It is empty unless an application explicitly wires creators into this package; YAML applications should use pkg/teamloader/toolsets.NewDefaultToolsetRegistry.
func NewToolsetRegistry ¶
func NewToolsetRegistry(creators map[string]ToolsetCreator) ToolsetRegistry
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package defaults wires docker-agent's full set of toolsets, model providers, agent sources and optional loader features into the team loader.
|
Package defaults wires docker-agent's full set of toolsets, model providers, agent sources and optional loader features into the team loader. |
|
Package toolsets wires every built-in toolset type into a teamloader.ToolsetRegistry.
|
Package toolsets wires every built-in toolset type into a teamloader.ToolsetRegistry. |