Documentation
¶
Index ¶
- Constants
- type ApprovalDecision
- type ApprovalRequest
- type Event
- type EventSink
- type EventType
- type ExecutionPolicy
- type ExecutionRequest
- type ExecutionResult
- type Executor
- type FilesystemContext
- type InteractionHandler
- type Message
- type ModelConfig
- type Observer
- type QuestionAnswer
- type QuestionItem
- type QuestionOption
- type QuestionRequest
- type Registry
- type Runtime
- type RuntimeResolver
- type Tool
- type ToolCallRecord
- type ToolDefinition
- type ToolResult
- type Usage
Constants ¶
const (
// RuntimeKindLeros is the built-in Leros agent runtime.
RuntimeKindLeros = "leros"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApprovalDecision ¶
type ApprovalDecision struct {
RequestID string
Action string // "approve" | "deny" | "always"
Reason string
}
ApprovalDecision is the user's response to an approval request.
type ApprovalRequest ¶
type ApprovalRequest struct {
RequestID string
ToolCallID string
ToolName string
Arguments json.RawMessage
Description string
Runtime string
}
ApprovalRequest carries the details needed for an approval decision.
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 json.RawMessage `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 ExecutionPolicy ¶
ExecutionPolicy controls generic runtime behavior.
type ExecutionRequest ¶
type ExecutionRequest struct {
ExecutionID string
TraceID string
Runtime string
SessionKey string
InstanceKey string
SystemPrompt string
Prompt string
Messages []Message
Model ModelConfig
Tools []Tool
Policy ExecutionPolicy
Filesystem FilesystemContext
}
ExecutionRequest is a fully prepared, business-neutral Runtime input.
type ExecutionResult ¶
type ExecutionResult struct {
Message string
Usage *Usage
ToolCalls []ToolCallRecord
ProviderConversationID string
}
ExecutionResult is the low-level result returned by a Runtime before business finalization.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor resolves a Runtime by name and drives the execution lifecycle:
- Validate the execution request.
- Resolve a Runtime implementation by name.
- Emit execution.started through the observer.
- Call Runtime.Execute.
- Handle cancellation propagation and observer errors.
- Emit execution.completed / execution.failed / execution.cancelled.
- Return ExecutionResult.
func NewExecutor ¶
NewExecutor creates an Executor backed by the given Registry.
func (*Executor) Execute ¶
func (e *Executor) Execute( ctx context.Context, request ExecutionRequest, observer Observer, ) (ExecutionResult, error)
Execute runs the full execution lifecycle for a prepared run.
type FilesystemContext ¶
FilesystemContext contains the already prepared runtime directories.
type InteractionHandler ¶
type InteractionHandler interface {
// RequestApproval asks for user approval on a tool call.
// It blocks until a decision is made or the context is cancelled.
RequestApproval(ctx context.Context, req *ApprovalRequest) (*ApprovalDecision, error)
// RequestAnswer asks the user to answer a set of questions.
// It blocks until answers are received or the context is cancelled.
RequestAnswer(ctx context.Context, req *QuestionRequest) (*QuestionAnswer, error)
}
InteractionHandler handles approval and question requests from a Runtime. It is injected at Runtime construction time; Runtime MUST NOT depend on a package-level default.
type ModelConfig ¶
ModelConfig is the fully resolved model configuration for one execution.
type Observer ¶
type Observer interface {
EventSink
}
Observer receives execution lifecycle events. An Observer that returns an error from any method terminates the execution.
type QuestionAnswer ¶
QuestionAnswer carries the user's response to a QuestionRequest.
type QuestionItem ¶
type QuestionItem struct {
Question string
Header string
Options []QuestionOption
MultiSelect bool
Custom bool
}
QuestionItem is a single question in a QuestionRequest.
type QuestionOption ¶
QuestionOption is one option for a QuestionItem.
type QuestionRequest ¶
type QuestionRequest struct {
RequestID string
SessionKey string
Questions []QuestionItem
ToolCallID string
Description string
Runtime string
}
QuestionRequest carries one or more questions from a Runtime.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maps runtime kind names to Runtime implementations. It is populated at composition root (cmd/leros/worker.go) and is read-only during execution.
func (*Registry) Register ¶
Register adds a Runtime implementation to the registry. name is normalized to lowercase before storage.
func (*Registry) Resolve ¶
Resolve returns the Runtime for the given kind. If kind is empty, the default is returned.
func (*Registry) SetDefault ¶
SetDefault sets the default runtime kind returned when Resolve receives an empty kind.
type Runtime ¶
type Runtime interface {
Name() string
Execute(ctx context.Context, request ExecutionRequest, observer Observer) (ExecutionResult, error)
}
Runtime executes a fully prepared request against a specific provider.
Runtime MUST NOT:
- Emit run.started, run.completed, run.failed, or run.cancelled events.
- Mutate ExecutionRequest.
- Access NATS, messaging, or Session persistence.
type RuntimeResolver ¶
RuntimeResolver maps a runtime kind string to a Runtime implementation.
type Tool ¶
type Tool interface {
// Definition returns the tool metadata (name, description, parameters schema).
Definition() ToolDefinition
// Execute runs the tool with the given JSON input.
Execute(ctx context.Context, input json.RawMessage) (ToolResult, error)
}
Tool is the contract for a callable tool within an agent Runtime. Implementations decode json.RawMessage into a typed request struct, execute the operation, and return a ToolResult.
type ToolCallRecord ¶
type ToolCallRecord struct {
CallID string `json:"call_id,omitempty"`
Name string `json:"name,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
ToolCallRecord is a compact final tool call summary.
type ToolDefinition ¶
type ToolDefinition struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Parameters json.RawMessage `json:"parameters,omitempty"`
}
ToolDefinition describes a tool exposed to a Runtime.
type ToolResult ¶
type ToolResult struct {
Content string `json:"content,omitempty"`
Error string `json:"error,omitempty"`
IsError bool `json:"is_error"`
}
ToolResult is the result returned by a tool execution.
Directories
¶
| Path | Synopsis |
|---|---|
|
runtime
|
|
|
claude
Package claude 将 Claude Code 适配到 Leros 外部 CLI 引擎接口。
|
Package claude 将 Claude Code 适配到 Leros 外部 CLI 引擎接口。 |
|
codex
Package codex 将 Codex CLI 适配到 Leros 外部 CLI 引擎接口。
|
Package codex 将 Codex CLI 适配到 Leros 外部 CLI 引擎接口。 |
|
events
Package events 定义共享的运行时事件契约。
|
Package events 定义共享的运行时事件契约。 |
|
externalcli
Package externalcli adapts external agent CLI providers to the agent.Runtime contract.
|
Package externalcli adapts external agent CLI providers to the agent.Runtime contract. |
|
native
Package native implements the built-in Eino-backed Leros runtime.
|
Package native implements the built-in Eino-backed Leros runtime. |
|
opencode
Package opencode 将 OpenCode CLI 适配到 Leros 外部 CLI 引擎接口。
|
Package opencode 将 OpenCode CLI 适配到 Leros 外部 CLI 引擎接口。 |