runtime

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentChoiceEvent

type AgentChoiceEvent struct {
	Type   string                   `json:"type"`
	Choice chat.MessageStreamChoice `json:"choice"`
	AgentContext
}

type AgentContext

type AgentContext struct {
	AgentName string `json:"agent_name,omitempty"`
}

AgentContext carries optional agent attribution for an event.

func (AgentContext) GetAgentName

func (a AgentContext) GetAgentName() string

GetAgentName returns the agent name for events embedding AgentContext.

type ErrorEvent

type ErrorEvent struct {
	Type  string `json:"type"`
	Error string `json:"error"`
	AgentContext
}

type Event

type Event interface {
	GetAgentName() string
	// contains filtered or unexported methods
}

func AgentChoice

func AgentChoice(agentName string, choice chat.MessageStreamChoice) Event

func Error

func Error(msg string) Event

func PartialToolCall

func PartialToolCall(toolCall tools.ToolCall, agentName string) Event

func SessionCompaction

func SessionCompaction(sessionID, status string) Event

func SessionSummary

func SessionSummary(sessionID, summary string) Event

func SessionTitle

func SessionTitle(sessionID, title string) Event

func ShellOutput added in v1.0.1

func ShellOutput(output string) Event

func StreamStarted

func StreamStarted() Event

func StreamStopped

func StreamStopped() Event

func TokenUsage

func TokenUsage(inputTokens, outputTokens, contextLength, contextLimit int, cost float64) Event

func ToolCall

func ToolCall(toolCall tools.ToolCall, agentName string) Event

func ToolCallConfirmation

func ToolCallConfirmation(toolCall tools.ToolCall, agentName string) Event

func ToolCallResponse

func ToolCallResponse(toolCall tools.ToolCall, response, agentName string) Event

func UserMessage

func UserMessage(message string) Event

type Opt

type Opt func(*Runtime)

func WithAutoRunTools

func WithAutoRunTools(autoRunTools bool) Opt

func WithCurrentAgent

func WithCurrentAgent(agentName string) Opt

func WithSessionCompaction

func WithSessionCompaction(sessionCompaction bool) Opt

func WithTracer

func WithTracer(t trace.Tracer) Opt

WithTracer sets a custom OpenTelemetry tracer; if not provided, tracing is disabled (no-op).

type PartialToolCallEvent

type PartialToolCallEvent struct {
	Type     string         `json:"type"`
	ToolCall tools.ToolCall `json:"tool_call"`
	AgentContext
}

ToolCallEvent is sent when a tool call is received PartialToolCallEvent is sent when a tool call is first received (partial/complete)

type ResumeType

type ResumeType string
const (
	ResumeTypeApprove        ResumeType = "approve"
	ResumeTypeApproveSession ResumeType = "approve-session"
	ResumeTypeReject         ResumeType = "reject"
)

type Runtime

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

Runtime manages the execution of agents

func New

func New(agents *team.Team, opts ...Opt) (*Runtime, error)

New creates a new runtime for an agent and its team

func (*Runtime) CurrentAgent

func (r *Runtime) CurrentAgent() *agent.Agent

func (*Runtime) Resume

func (r *Runtime) Resume(_ context.Context, confirmationType string)

func (*Runtime) Run

func (r *Runtime) Run(ctx context.Context, sess *session.Session) ([]session.Message, error)

Run starts the agent's interaction loop

func (*Runtime) RunStream

func (r *Runtime) RunStream(ctx context.Context, sess *session.Session) <-chan Event

Run starts the agent's interaction loop

func (*Runtime) Summarize

func (r *Runtime) Summarize(ctx context.Context, sess *session.Session, events chan Event)

Summarize generates a summary for the session based on the conversation history

func (*Runtime) Team

func (r *Runtime) Team() *team.Team

type SessionCompactionEvent

type SessionCompactionEvent struct {
	Type      string `json:"type"`
	SessionID string `json:"session_id"`
	Status    string `json:"status"`
	AgentContext
}

type SessionSummaryEvent

type SessionSummaryEvent struct {
	Type      string `json:"type"`
	SessionID string `json:"session_id"`
	Summary   string `json:"summary"`
	AgentContext
}

type SessionTitleEvent

type SessionTitleEvent struct {
	Type      string `json:"type"`
	SessionID string `json:"session_id"`
	Title     string `json:"title"`
	AgentContext
}

type ShellOutputEvent added in v1.0.1

type ShellOutputEvent struct {
	Type   string `json:"type"`
	Output string `json:"error"`
}

func (*ShellOutputEvent) GetAgentName added in v1.0.1

func (e *ShellOutputEvent) GetAgentName() string

type StreamStartedEvent

type StreamStartedEvent struct {
	Type string `json:"type"`
}

func (*StreamStartedEvent) GetAgentName

func (e *StreamStartedEvent) GetAgentName() string

type StreamStoppedEvent

type StreamStoppedEvent struct {
	Type string `json:"type"`
}

func (*StreamStoppedEvent) GetAgentName

func (e *StreamStoppedEvent) GetAgentName() string

type TokenUsageEvent

type TokenUsageEvent struct {
	Type  string `json:"type"`
	Usage *Usage `json:"usage"`
	AgentContext
}

type ToolCallConfirmationEvent

type ToolCallConfirmationEvent struct {
	Type     string         `json:"type"`
	ToolCall tools.ToolCall `json:"tool_call"`
	AgentContext
}

type ToolCallEvent

type ToolCallEvent struct {
	Type     string         `json:"type"`
	ToolCall tools.ToolCall `json:"tool_call"`
	AgentContext
}

type ToolCallResponseEvent

type ToolCallResponseEvent struct {
	Type     string         `json:"type"`
	ToolCall tools.ToolCall `json:"tool_call"`
	Response string         `json:"response"`
	AgentContext
}

type ToolHandler

type ToolHandler func(ctx context.Context, sess *session.Session, toolCall tools.ToolCall, events chan Event) (*tools.ToolCallResult, error)

ToolHandler is a function type for handling tool calls

type Usage

type Usage struct {
	InputTokens   int     `json:"input_tokens"`
	OutputTokens  int     `json:"output_tokens"`
	ContextLength int     `json:"context_length"`
	ContextLimit  int     `json:"context_limit"`
	Cost          float64 `json:"cost"`
}

type UserMessageEvent

type UserMessageEvent struct {
	Type    string `json:"type"`
	Message string `json:"message"`
}

UserMessageEvent is sent when a user message is received

func (*UserMessageEvent) GetAgentName

func (e *UserMessageEvent) GetAgentName() string

Jump to

Keyboard shortcuts

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