Documentation
¶
Overview ¶
Package agent provides a Go harness for building model-backed agents, registering tools, managing memory, and composing teams and workflows.
Start with New and Harness.NewAgent for the common path. The model, memory, tool, engine, workflow, security, types, and mcp subpackages expose extension points for applications that need custom implementations or direct access.
Index ¶
- func ResolveModelDefaults(cfg *ModelConfig)
- type Config
- type Harness
- func (h *Harness) Agent(name string) (*engine.Agent, bool)
- func (h *Harness) AllowPermissions(permissions ...security.Permission)
- func (h *Harness) CheckPermission(permission security.Permission) error
- func (h *Harness) Close() error
- func (h *Harness) Config() Config
- func (h *Harness) DenyPermissions(permissions ...security.Permission)
- func (h *Harness) InitMCPClients(ctx context.Context) error
- func (h *Harness) Model() model.Model
- func (h *Harness) NewAgent(name, systemPrompt string) *engine.Agent
- func (h *Harness) NewTeam(cfg workflow.TeamConfig) *workflow.Team
- func (h *Harness) NewWorkflow(cfg workflow.WorkflowConfig) *workflow.Workflow
- func (h *Harness) RegisterAgent(runtimeAgent *engine.Agent) error
- func (h *Harness) RegisterTeam(team *workflow.Team) error
- func (h *Harness) RegisterTool(runtimeTool tool.Tool) error
- func (h *Harness) RegisterWorkflow(runtimeWorkflow *workflow.Workflow) error
- func (h *Harness) RunAgent(ctx context.Context, name, input string, options ...engine.RunOption) *engine.RunOutput
- func (h *Harness) RunTeam(ctx context.Context, name, input string) *workflow.TeamOutput
- func (h *Harness) RunWorkflow(ctx context.Context, name, input string) *workflow.WorkflowResult
- func (h *Harness) Sanitize(input string) string
- func (h *Harness) Team(name string) (*workflow.Team, bool)
- func (h *Harness) ToolRegistry() *tool.Registry
- func (h *Harness) ValidateInput(input string) error
- func (h *Harness) ValidateOutput(output string) error
- func (h *Harness) Workflow(name string) (*workflow.Workflow, bool)
- type MCPClientConfig
- type MemoryConfig
- type ModelConfig
- type Option
- type SecurityConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResolveModelDefaults ¶
func ResolveModelDefaults(cfg *ModelConfig)
ResolveModelDefaults normalizes vendor/api_format and timeout. BaseURL is never inferred from vendor ? configure it explicitly (vendor and api_format are independent).
Types ¶
type Config ¶
type Config struct {
Version string `json:"version"`
Name string `json:"name"`
LogLevel string `json:"log_level"`
DefaultModel ModelConfig `json:"default_model"`
AllowedTools []string `json:"allowed_tools"`
MemoryConfig MemoryConfig `json:"memory"`
PermissionMode string `json:"permission_mode"` // strict, permissive
MCPClients []MCPClientConfig `json:"mcp_clients,omitempty"`
Security SecurityConfig `json:"security"`
}
func DefaultConfig ¶
func DefaultConfig() Config
func LoadConfig ¶
type Harness ¶
type Harness struct {
// contains filtered or unexported fields
}
func (*Harness) AllowPermissions ¶
func (h *Harness) AllowPermissions(permissions ...security.Permission)
func (*Harness) CheckPermission ¶
func (h *Harness) CheckPermission(permission security.Permission) error
func (*Harness) DenyPermissions ¶
func (h *Harness) DenyPermissions(permissions ...security.Permission)
func (*Harness) NewWorkflow ¶
func (h *Harness) NewWorkflow(cfg workflow.WorkflowConfig) *workflow.Workflow
func (*Harness) RegisterAgent ¶ added in v0.2.0
func (*Harness) RegisterWorkflow ¶
func (*Harness) RunWorkflow ¶
func (*Harness) ToolRegistry ¶
func (*Harness) ValidateInput ¶
func (*Harness) ValidateOutput ¶
type MCPClientConfig ¶
type MemoryConfig ¶
type ModelConfig ¶
type ModelConfig struct {
Vendor string `json:"vendor"` // deepseek / openai / anthropic / custom (logging / identity)
APIFormat string `json:"api_format"` // openai_response / openai_chat_completions / anthropic_message / mock
BaseURL string `json:"base_url,omitempty"`
APIKey string `json:"api_key,omitempty"`
ModelID string `json:"model_id"`
Timeout int `json:"timeout_seconds"`
}
ModelConfig describes which vendor and API protocol to use. Vendor and APIFormat are independent: BuildModel selects the client by APIFormat only; BaseURL/APIKey/ModelID come from config as-is.
func (ModelConfig) BuildModel ¶
func (c ModelConfig) BuildModel() (model.Model, error)
type Option ¶ added in v0.2.0
type Option func(*harnessOptions)
Option customizes Harness dependencies without changing the serializable Config format.
func WithInputValidator ¶ added in v0.2.0
func WithInputValidator(validator security.InputValidator) Option
func WithOutputValidator ¶ added in v0.2.0
func WithOutputValidator(validator security.OutputValidator) Option
func WithPermissionManager ¶ added in v0.2.0
func WithPermissionManager(manager security.PermissionManager) Option
func WithSanitizer ¶ added in v0.2.0
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
jd-cs-service
command
|
|
|
Package engine implements Agent execution, tool-call loops, streaming, and per-run options.
|
Package engine implements Agent execution, tool-call loops, streaming, and per-run options. |
|
examples
|
|
|
jdcs
Package jdcs demonstrates a customer-service application built exclusively from tracklogic-agent's public packages.
|
Package jdcs demonstrates a customer-service application built exclusively from tracklogic-agent's public packages. |
|
Package mcp implements a public Model Context Protocol client and converts remote MCP tools into tracklogic-agent model tool definitions.
|
Package mcp implements a public Model Context Protocol client and converts remote MCP tools into tracklogic-agent model tool definitions. |
|
Package memory defines conversation memory and provides a concurrent buffer implementation.
|
Package memory defines conversation memory and provides a concurrent buffer implementation. |
|
Package model defines the model abstraction and built-in OpenAI, Anthropic, Chat Completions, and mock implementations.
|
Package model defines the model abstraction and built-in OpenAI, Anthropic, Chat Completions, and mock implementations. |
|
Package security defines replaceable permission, validation, and sanitizing components together with default in-memory implementations.
|
Package security defines replaceable permission, validation, and sanitizing components together with default in-memory implementations. |
|
Package tool defines executable Agent tools and a concurrent registry.
|
Package tool defines executable Agent tools and a concurrent registry. |
|
builtin
Package builtin provides general-purpose tools for files, HTTP, JSON, calculation, directories, and time.
|
Package builtin provides general-purpose tools for files, HTTP, JSON, calculation, directories, and time. |
|
Package types contains stable protocol values shared across the model, memory, security, and engine layers.
|
Package types contains stable protocol values shared across the model, memory, security, and engine layers. |
|
Package workflow composes engine Agents into teams and stateful workflows.
|
Package workflow composes engine Agents into teams and stateful workflows. |