agentd

package
v0.0.0-...-05c9738 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventRunStarted    = "run.started"
	EventMessageDelta  = "message.delta"
	EventToolStarted   = "tool.started"
	EventToolOutput    = "tool.output"
	EventToolCompleted = "tool.completed"
	EventRunCompleted  = "run.completed"
	EventRunFailed     = "run.failed"
	EventRunCancelled  = "run.cancelled"
	EventPing          = "ping"
)
View Source
const (
	EventTrajectoryRecord = "trajectory.record"

	TrajectoryRunStarted  = "run.started"
	TrajectoryModelInput  = "model.input"
	TrajectoryModelOutput = "model.output"
	TrajectoryToolResult  = "tool.result"
	TrajectoryRunFinished = "run.finished"
)
View Source
const DefaultSystemPrompt = `` /* 427-byte string literal not displayed */

Variables

View Source
var ErrConversationBusy = errors.New("conversation already has an active run")

Functions

func NewLocalTools

func NewLocalTools(workspaceRoot string, skills *SkillRegistry) ([]tool.BaseTool, error)

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

func NewAgent

func NewAgent(ctx context.Context, chatModel model.ToolCallingChatModel, tools []tool.BaseTool, memory *MemoryStore, systemPrompt string) (*Agent, error)

func (*Agent) Cancel

func (a *Agent) Cancel(runID string) bool

func (*Agent) Run

func (a *Agent) Run(parent context.Context, conversationID, userMessage string, emit func(Event) error) (runID string, err error)

func (*Agent) RunWithID

func (a *Agent) RunWithID(parent context.Context, runID, conversationID, userMessage string, captureTrajectory bool, emit func(Event) error) (_ string, err error)

func (*Agent) RunWithOptions

func (a *Agent) RunWithOptions(parent context.Context, conversationID, userMessage string, captureTrajectory bool, emit func(Event) error) (runID string, err error)

type Config

type Config struct {
	Port string

	WorkspaceRoot    string
	BuiltinSkillsDir string
	MCPConfigPaths   []string

	Model         string
	ModelBaseURL  string
	ModelAPIKey   string
	SummaryModel  string
	SystemPrompt  string
	ContextTokens int

	AuthEnabled          bool
	SandboxJWTPublicPath string
	SandboxJWTIssuer     string
	SandboxJWTAudience   string
	SandboxJWTClockSkew  time.Duration
}

type DecisionReplayReport

type DecisionReplayReport struct {
	Mode         string               `json:"mode"`
	Status       string               `json:"status"`
	TotalSteps   int                  `json:"total_steps"`
	MatchedSteps int                  `json:"matched_steps"`
	Score        float64              `json:"score"`
	Steps        []DecisionReplayStep `json:"steps"`
	Output       string               `json:"output,omitempty"`
	Error        string               `json:"error,omitempty"`
}

type DecisionReplayRequest

type DecisionReplayRequest struct {
	Records []TrajectoryRecord `json:"records"`
}

type DecisionReplayStep

type DecisionReplayStep struct {
	Step           int              `json:"step"`
	Matched        bool             `json:"matched"`
	Expected       []ReplayToolCall `json:"expected"`
	Actual         []ReplayToolCall `json:"actual"`
	ContentChanged bool             `json:"content_changed"`
}

type Event

type Event struct {
	Type           string `json:"type"`
	RunID          string `json:"run_id"`
	ConversationID string `json:"conversation_id"`
	Sequence       int64  `json:"sequence"`
	Timestamp      string `json:"timestamp"`
	Payload        any    `json:"payload,omitempty"`
}

type MCPManager

type MCPManager struct {
	// contains filtered or unexported fields
}

func LoadMCPTools

func LoadMCPTools(ctx context.Context, paths []string) ([]tool.BaseTool, *MCPManager, error)

func (*MCPManager) Close

func (m *MCPManager) Close() error

type MemoryStore

type MemoryStore struct {
	// contains filtered or unexported fields
}

func NewMemoryStore

func NewMemoryStore(workspaceRoot string, contextTokens int, compressionModels ...string) *MemoryStore

func (*MemoryStore) Append

func (s *MemoryStore) Append(conversationID string, message *schema.Message) error

func (*MemoryStore) Context

func (s *MemoryStore) Context(ctx context.Context, conversationID, systemPrompt string, chatModel model.BaseChatModel) ([]*schema.Message, error)

func (*MemoryStore) Messages

func (s *MemoryStore) Messages(conversationID string) ([]*schema.Message, error)

type ReplayToolCall

type ReplayToolCall struct {
	Name      string `json:"name"`
	Arguments string `json:"arguments"`
}

type RunManager

type RunManager struct {
	// contains filtered or unexported fields
}

func NewRunManager

func NewRunManager(agent *Agent, root string) (*RunManager, error)

func (*RunManager) Cancel

func (m *RunManager) Cancel(runID string) bool

func (*RunManager) Close

func (m *RunManager) Close()

func (*RunManager) Get

func (m *RunManager) Get(runID string) (*RunState, bool)

func (*RunManager) Start

func (m *RunManager) Start(runID, conversationID, message string, captureTrajectory bool) (*RunState, bool, error)

func (*RunManager) Subscribe

func (m *RunManager) Subscribe(ctx context.Context, runID string, after int64, send func(Event) error, ping func() error) error

type RunState

type RunState struct {
	RunID          string `json:"run_id"`
	ConversationID string `json:"conversation_id"`
	Status         string `json:"status"`
	LastSequence   int64  `json:"last_sequence"`
	Error          string `json:"error,omitempty"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ctx context.Context, cfg *Config) (*Server, error)

func (*Server) Close

func (s *Server) Close() error

func (*Server) Serve

func (s *Server) Serve(ctx context.Context) error

type SkillRegistry

type SkillRegistry struct {
	// contains filtered or unexported fields
}

func LoadSkills

func LoadSkills(builtinDir, workspaceRoot string) (*SkillRegistry, error)

func (*SkillRegistry) Index

func (r *SkillRegistry) Index() string

func (*SkillRegistry) Read

func (r *SkillRegistry) Read(name string) (string, error)

type TrajectoryRecord

type TrajectoryRecord struct {
	Version        int             `json:"version"`
	RunID          string          `json:"run_id"`
	ConversationID string          `json:"conversation_id"`
	Sequence       int64           `json:"sequence"`
	Type           string          `json:"type"`
	Step           int             `json:"step,omitempty"`
	Timestamp      string          `json:"timestamp"`
	Payload        json.RawMessage `json:"payload,omitempty"`
	PreviousHash   string          `json:"previous_hash,omitempty"`
	Hash           string          `json:"hash"`
}

type TrajectoryStore

type TrajectoryStore struct {
	// contains filtered or unexported fields
}

func NewTrajectoryStore

func NewTrajectoryStore(workspaceRoot string) *TrajectoryStore

func (*TrajectoryStore) Append

func (s *TrajectoryStore) Append(runID, conversationID, recordType string, step int, payload any) (*TrajectoryRecord, error)

func (*TrajectoryStore) Records

func (s *TrajectoryStore) Records(runID string) ([]TrajectoryRecord, error)

Jump to

Keyboard shortcuts

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