agentcore

package
v0.59.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ToolNameAskUser   = tools.AskUserToolName
	ToolNameBash      = tools.BashToolName
	ToolNameCallMCP   = tools.CallMCPToolName
	ToolNameDelegate  = tools.DelegateToolName
	ToolNameEditFile  = tools.EditFileToolName
	ToolNameGlob      = tools.GlobToolName
	ToolNameGrep      = tools.GrepToolName
	ToolNameReadFile  = tools.ReadFileToolName
	ToolNameWebFetch  = tools.WebFetchToolName
	ToolNameWriteFile = tools.WriteFileToolName
)

Variables

This section is empty.

Functions

func ActivationMessage

func ActivationMessage(skill Skill, args []string) (string, error)

func SaveSkillsConfig

func SaveSkillsConfig(cfg SkillsConfig) error

func ToCoreMessages

func ToCoreMessages(messages []Message) []core.Message

func ToCoreTurnMemory

func ToCoreTurnMemory(memory *TurnMemory) *core.TurnMemory

func ToToolDiffLines

func ToToolDiffLines(lines []EditDiffLine) []tools.EditDiffLine

Types

type AgentCore

type AgentCore interface {
	IsReady() bool
	UpdateClient() error
	ClearClient()
	IsAdversaryReady() bool
	SetAdversaryClient() error
	ResetClientState()

	Mode() Mode
	SetMode(Mode)

	FormatUserMessage(content string) string
	AppendMessage(message Message)
	GetMessages() []Message
	ClearMessages()
	ReplaceMessages(messages []Message)
	ApplyCompaction(summary string) error
	ClearContextMetrics()
	WithoutSystemMessages(messages []Message) []Message

	Submit(ctx context.Context, sessionID string, input string) (<-chan StreamEvent, error)
	Compact(ctx context.Context, sessionID string, hint string) (<-chan StreamEvent, error)
	Btw(ctx context.Context, question string) (<-chan StreamEvent, error)
	Adversary(ctx context.Context, focus string) (<-chan StreamEvent, error)

	GetContextBreakdown() ContextBreakdown
	GetLastUsage() *TokenUsage
	SetLastUsage(usage *TokenUsage)

	ReloadSkills() SkillsDiscovery
	GetSkills() SkillsDiscovery
	GetSkillsConfig() SkillsConfig
	SetSkillStatus(name string, status SkillStatus) error
	RemoveSkillStatus(name string) error
	FindEnabledSkill(name string) (Skill, bool)
	SkillSuggestions() []Skill
	SkillsCatalog() string

	ReloadSubagents() SubagentsDiscovery
	GetSubagents() SubagentsDiscovery
	SubagentsCatalog() string

	WorkingDir() string
	RegisteredToolNames() []string

	Config() *config.ResolvedConfig
	SetConfig(cfg *config.ResolvedConfig)
	GlobalConfig() *config.GlobalConfig
	SetGlobalConfig(cfg *config.GlobalConfig)

	SetupTools(
		ctx context.Context,
		permissionRequester PermissionRequester,
		diffEmitter DiffEmitter,
		askUserRequester AskUserRequester,
		mcpRuntime keenmcp.Runtime,
		forwardActivity bool,
		usageSink chan<- usage.Record,
	) <-chan ToolActivity
}

AgentCore is the UI-facing boundary to the backend agent.

func New

func New(client llm.LLMClient, workingDir string, cfg *config.ResolvedConfig, globalCfg *config.GlobalConfig) AgentCore

type AskUserQuestion

type AskUserQuestion struct {
	Question string   `json:"question"`
	Options  []string `json:"options"`
}

type AskUserRequest

type AskUserRequest struct {
	Questions []AskUserQuestion `json:"questions"`
}

type AskUserRequester

type AskUserRequester interface {
	RequestUser(ctx context.Context, questionnaire AskUserRequest) (AskUserResult, error)
}

type AskUserResult

type AskUserResult struct {
	Answers   []string `json:"answers"`
	Cancelled bool     `json:"cancelled"`
}

type AutoCompactionEvent

type AutoCompactionEvent struct {
	Cancel      func()
	Replacement []Message
	Usage       *TokenUsage
	Error       error
}

type ContextBreakdown

type ContextBreakdown struct {
	SystemPromptTokens  int
	ToolDefinitionCount int
	ToolDefTokens       int
	UserMessageTokens   int
	AssistantTokens     int
	ToolResultTokens    int
	TotalEstimated      int
}

type DiffEmitter

type DiffEmitter interface {
	EmitDiff(lines []EditDiffLine)
}

type EditDiffLine

type EditDiffLine struct {
	Kind       EditDiffLineKind
	OldLineNum int
	NewLineNum int
	Content    string
}

func FromToolDiffLines

func FromToolDiffLines(lines []tools.EditDiffLine) []EditDiffLine

type EditDiffLineKind

type EditDiffLineKind int
const (
	EditDiffLineContext EditDiffLineKind = iota
	EditDiffLineAdded
	EditDiffLineRemoved
	EditDiffLineHunk
)

type HistoricalToolActivity

type HistoricalToolActivity struct {
	TextOffset     int            `json:"text_offset"`
	Tool           string         `json:"tool"`
	Input          map[string]any `json:"input,omitempty"`
	Status         string         `json:"status"`
	ExitCode       *int           `json:"exit_code,omitempty"`
	HasRawOutput   bool           `json:"-"`
	RawOutput      any            `json:"-"`
	RetainedOutput any            `json:"retained_output,omitempty"`
}

type Message

type Message struct {
	Role       Role
	Content    string
	TurnMemory *TurnMemory
}

func FromCoreMessages

func FromCoreMessages(messages []core.Message) []Message

type Mode

type Mode string
const (
	ModePlan  Mode = "plan"
	ModeBuild Mode = "build"
	ModeYolo  Mode = "yolo"
)

type PermissionRequester

type PermissionRequester interface {
	RequestPermission(ctx context.Context, toolName, path, resolvedPath string, isDangerous bool) (bool, error)
}

type Role

type Role string
const (
	RoleSystem    Role = "system"
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
)

type Skill

type Skill struct {
	Name        string
	Description string
	Location    string
}

func FindSkill

func FindSkill(skills []Skill, name string) (Skill, bool)

type SkillStatus

type SkillStatus bool
const (
	SkillStatusDisabled SkillStatus = false
	SkillStatusEnabled  SkillStatus = true
)

type SkillsConfig

type SkillsConfig struct {
	IsEnabled map[string]bool `json:"is_enabled"`
}

func LoadSkillsConfig

func LoadSkillsConfig() SkillsConfig

func (SkillsConfig) Enabled

func (c SkillsConfig) Enabled(name string) bool

type SkillsDiscovery

type SkillsDiscovery struct {
	Skills   []Skill
	Warnings []string
}

type StreamEvent

type StreamEvent struct {
	Type           StreamEventType
	Content        string
	Error          error
	ToolCall       *ToolCall
	Usage          *TokenUsage
	Attempt        int
	AutoCompaction *AutoCompactionEvent
}

type StreamEventType

type StreamEventType string
const (
	StreamEventTypeChunk                   StreamEventType = "chunk"
	StreamEventTypeReasoningChunk          StreamEventType = "reasoning_chunk"
	StreamEventTypeDone                    StreamEventType = "done"
	StreamEventTypeError                   StreamEventType = "error"
	StreamEventTypeToolStart               StreamEventType = "tool_start"
	StreamEventTypeToolEnd                 StreamEventType = "tool_end"
	StreamEventTypeUsage                   StreamEventType = "usage"
	StreamEventTypeRetry                   StreamEventType = "retry"
	StreamEventTypeIncomplete              StreamEventType = "incomplete"
	StreamEventTypeAutoCompactionStarted   StreamEventType = "auto_compaction_started"
	StreamEventTypeAutoCompactionApplied   StreamEventType = "auto_compaction_applied"
	StreamEventTypeAutoCompactionCancelled StreamEventType = "auto_compaction_cancelled"
	StreamEventTypeAutoCompactionFailed    StreamEventType = "auto_compaction_failed"
)

type SubagentProfile

type SubagentProfile struct {
	Name        string
	Description string
	Hidden      bool
}

type SubagentsDiscovery

type SubagentsDiscovery struct {
	Profiles []SubagentProfile
	Warnings []string
}

type TokenUsage

type TokenUsage struct {
	InputTokens      int
	OutputTokens     int
	TotalTokens      int
	ReasoningTokens  int
	CachedTokens     int
	CacheReadTokens  int
	CacheWriteTokens int
}

type ToolActivity

type ToolActivity struct {
	RunID  string
	CallID string
	Agent  string
	Event  StreamEvent
}

func ConvertToolActivity

func ConvertToolActivity(activity subagents.ToolActivity) ToolActivity

type ToolCall

type ToolCall struct {
	Name     string
	Input    map[string]any
	Output   any
	Error    string
	Duration time.Duration
}

type TurnMemory

type TurnMemory struct {
	ToolActivity []HistoricalToolActivity `json:"tool_activity,omitempty"`
}

func CloneTurnMemory

func CloneTurnMemory(memory *TurnMemory) *TurnMemory

func (*TurnMemory) IsEmpty

func (m *TurnMemory) IsEmpty() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL