Documentation
¶
Index ¶
- Constants
- func BuildUserInput(req *RequestContext) string
- type ActorContext
- type AssistantContext
- type Attachment
- type CapabilityContext
- type ConversationContext
- type Event
- type EventSink
- type EventType
- type InputContext
- type InputMessage
- type InputType
- type ModelOptions
- type PolicyContext
- type RawPayload
- type RequestContext
- type RunResult
- type RunStatus
- type Runner
- type RuntimeOptions
- type RuntimeRouter
- type ToolCallRecord
- type Usage
- type WorkspaceContext
Constants ¶
const (
// RuntimeKindLeros is the built-in Leros agent runtime.
RuntimeKindLeros = "leros"
)
Variables ¶
This section is empty.
Functions ¶
func BuildUserInput ¶
func BuildUserInput(req *RequestContext) string
BuildUserInput joins the user-side messages from the request into a formatted text.
Types ¶
type ActorContext ¶
type ActorContext struct {
UserID string `json:"user_id"`
DisplayName string `json:"display_name,omitempty"`
Channel string `json:"channel,omitempty"`
ExternalID string `json:"external_id,omitempty"`
AccountID string `json:"account_id,omitempty"`
}
ActorContext describes the human or system actor that initiated the run.
type AssistantContext ¶
type AssistantContext struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Role string `json:"role,omitempty"`
SystemPrompt string `json:"system_prompt,omitempty"`
Skills []string `json:"skills,omitempty"`
Tools []string `json:"tools,omitempty"`
}
AssistantContext is the assistant snapshot used for one run.
type Attachment ¶
type Attachment struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
MimeType string `json:"mime_type,omitempty"`
URL string `json:"url,omitempty"`
}
Attachment describes an input attachment made available to the run.
type CapabilityContext ¶
type CapabilityContext struct {
AllowedTools []string `json:"allowed_tools,omitempty"`
}
CapabilityContext describes allowed capabilities for one run.
type ConversationContext ¶
type ConversationContext struct {
ID string `json:"id,omitempty"`
Messages []InputMessage `json:"messages,omitempty"`
}
ConversationContext carries recent conversation state when available.
type Event ¶
type Event struct {
ID string `json:"id,omitempty"`
RunID string `json:"run_id,omitempty"`
TraceID string `json:"trace_id,omitempty"`
Seq int64 `json:"seq,omitempty"`
Type EventType `json:"type"`
CreatedAt time.Time `json:"created_at,omitempty"`
Payload RawPayload `json:"payload,omitempty"`
Content string `json:"content,omitempty"`
}
Event is the stable runtime event envelope emitted during execution.
type EventType ¶
type EventType string
EventType identifies an observable runtime event emitted during execution.
type InputContext ¶
type InputContext struct {
Type InputType `json:"type"`
Messages []InputMessage `json:"messages,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
}
InputContext is the normalized input passed to the agent.
type InputMessage ¶
InputMessage is a simple role/content message snapshot.
type ModelOptions ¶
type ModelOptions struct {
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
APIKey string `json:"-"`
BaseURL string `json:"base_url,omitempty"`
BaseURLHasV1 bool `json:"base_url_has_v1,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
}
ModelOptions lets callers override model behavior when supported.
type PolicyContext ¶
type PolicyContext struct {
RequireApproval bool `json:"require_approval,omitempty"`
PermissionMode string `json:"permission_mode,omitempty"` // "bypass" | "on-request" | "auto"; empty defaults to bypass
}
PolicyContext carries policy knobs for one run.
type RawPayload ¶
type RawPayload json.RawMessage
RawPayload stores structured event payload JSON while keeping Event easy to marshal.
func (RawPayload) MarshalJSON ¶
func (p RawPayload) MarshalJSON() ([]byte, error)
MarshalJSON serializes the raw payload bytes.
func (*RawPayload) UnmarshalJSON ¶
func (p *RawPayload) UnmarshalJSON(data []byte) error
UnmarshalJSON stores the raw payload bytes.
type RequestContext ¶
type RequestContext struct {
RunID string `json:"run_id"`
TraceID string `json:"trace_id,omitempty"`
TaskID string `json:"task_id,omitempty"`
Assistant AssistantContext `json:"assistant"`
Actor ActorContext `json:"actor"`
Conversation ConversationContext `json:"conversation,omitempty"`
Workspace WorkspaceContext `json:"workspace,omitempty"`
Input InputContext `json:"input"`
Runtime RuntimeOptions `json:"runtime,omitempty"`
Model ModelOptions `json:"model,omitempty"`
Capability CapabilityContext `json:"capability,omitempty"`
Policy PolicyContext `json:"policy,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
SystemPrompt string `json:"-"`
EventSink EventSink `json:"-"`
}
RequestContext is the normalized execution snapshot consumed by runtime.
type RunResult ¶
type RunResult struct {
RunID string `json:"run_id"`
TraceID string `json:"trace_id,omitempty"`
Status RunStatus `json:"status"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
Usage *Usage `json:"usage,omitempty"`
ToolCalls []ToolCallRecord `json:"tool_calls,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
StartedAt time.Time `json:"started_at"`
CompletedAt time.Time `json:"completed_at,omitempty"`
}
RunResult is the final result of one agent run.
type Runner ¶
type Runner interface {
Run(ctx context.Context, req *RequestContext) (*RunResult, error)
}
Runner executes one normalized agent request.
type RuntimeOptions ¶
type RuntimeOptions struct {
Kind string `json:"kind,omitempty"`
WorkDir string `json:"work_dir,omitempty"`
MaxStep int `json:"max_step,omitempty"`
}
RuntimeOptions controls runtime execution behavior.
type RuntimeRouter ¶
type RuntimeRouter struct {
// contains filtered or unexported fields
}
RuntimeRouter 根据请求选择具体 runtime。
func NewRuntimeRouter ¶
func NewRuntimeRouter(defaultKind string) *RuntimeRouter
NewRuntimeRouter 创建带默认 runtime 的路由器。
func (*RuntimeRouter) Register ¶
func (r *RuntimeRouter) Register(kind string, runner Runner) error
Register 注册或替换一个 runtime runner。
func (*RuntimeRouter) Run ¶
func (r *RuntimeRouter) Run(ctx context.Context, req *RequestContext) (*RunResult, error)
Run 使用请求指定的 runtime 执行任务。
func (*RuntimeRouter) SetDefault ¶
func (r *RuntimeRouter) SetDefault(kind string)
SetDefault 更新默认 runtime。
type ToolCallRecord ¶
type ToolCallRecord struct {
CallID string `json:"call_id,omitempty"`
Name string `json:"name,omitempty"`
Result map[string]any `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
ToolCallRecord is a compact final tool call summary.