Documentation
¶
Index ¶
- Constants
- Variables
- func WithContext(ctx context.Context, subCtx Context) context.Context
- func WithDispatchSource(ctx context.Context, source string) context.Context
- func WithTaskDispatch(ctx context.Context) context.Context
- type Context
- type Definition
- type Handler
- type HandlerFunc
- type LoaderOptions
- type Manager
- type Request
- type Result
- type SubagentFile
- type SubagentMetadata
- type SubagentRegistration
Constants ¶
const ( TypeGeneralPurpose = "general-purpose" TypeExplore = "explore" TypePlan = "plan" ModelSonnet = "sonnet" ModelHaiku = "haiku" )
const DispatchSourceTaskTool = "task_tool"
Variables ¶
Functions ¶
func WithContext ¶
WithContext stores the runtime Context inside ctx for downstream consumers.
func WithDispatchSource ¶
WithDispatchSource tags ctx with an allowed dispatch origin.
Types ¶
type Context ¶
type Context struct {
SessionID string
Metadata map[string]any
ToolWhitelist []string
Model string
}
Context stores execution metadata for an individual subagent run.
func FromContext ¶
FromContext retrieves a Context previously injected with WithContext.
func (Context) Allows ¶
Allows reports whether the tool may be used under this context. Empty whitelists imply full access for backward compatibility with legacy agents.
func (Context) RestrictTools ¶
RestrictTools narrows the tool whitelist to the provided names.
func (Context) ToolList ¶
ToolList returns the current whitelist (sorted, deduplicated) for inspection.
func (Context) WithMetadata ¶
WithMetadata merges metadata into the context.
func (Context) WithSession ¶
WithSession sets the session identifier when provided.
type Definition ¶
type Definition struct {
Name string
Description string
Priority int
MutexKey string
BaseContext Context
Matchers []skills.Matcher
DefaultModel string
}
Definition describes a single subagent.
func BuiltinDefinition ¶
func BuiltinDefinition(name string) (Definition, bool)
BuiltinDefinition looks up a predefined subagent type by name.
func BuiltinDefinitions ¶
func BuiltinDefinitions() []Definition
BuiltinDefinitions returns the predefined metadata for core subagent types.
func (Definition) Validate ¶
func (d Definition) Validate() error
Validate ensures the definition is safe to register.
type HandlerFunc ¶
HandlerFunc adapts a function to Handler.
type LoaderOptions ¶
type LoaderOptions struct {
ProjectRoot string
// Deprecated: user-level scanning has been removed; this field is ignored.
UserHome string
// Deprecated: user-level scanning has been removed; this flag is ignored.
EnableUser bool
FS *config.FS
}
LoaderOptions controls how subagents are discovered from the filesystem.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func (*Manager) Dispatch ¶
Dispatch selects and executes a subagent. When Target is empty, automatic matchers choose the best candidate subject to priority/mutex ordering.
func (*Manager) List ¶
func (m *Manager) List() []Definition
List returns registered subagent definitions sorted by priority + name.
type Request ¶
type Request struct {
Target string
Instruction string
Activation skills.ActivationContext
ToolWhitelist []string
Metadata map[string]any
}
Request carries execution parameters for a subagent run.
type SubagentFile ¶
type SubagentFile struct {
Name string
Path string
Metadata SubagentMetadata
Body string
}
SubagentFile captures an on-disk subagent definition.
type SubagentMetadata ¶
type SubagentMetadata struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Tools string `yaml:"tools"` // comma separated
Model string `yaml:"model"` // sonnet/opus/haiku/inherit
PermissionMode string `yaml:"permissionMode"` // default/acceptEdits/bypassPermissions/plan/ignore
Skills string `yaml:"skills"` // comma separated
}
SubagentMetadata mirrors the YAML frontmatter fields.
type SubagentRegistration ¶
type SubagentRegistration struct {
Definition Definition
Handler Handler
}
SubagentRegistration wires a definition to its handler.
func LoadFromFS ¶
func LoadFromFS(opts LoaderOptions) ([]SubagentRegistration, []error)
LoadFromFS loads subagent definitions. Errors are aggregated so a single bad file will not block other registrations.