Documentation
¶
Index ¶
- func ValidateWorkflowRequest(req WorkflowRequest) error
- type AgentDeclaration
- type AgentToolReference
- type ApprovalRequestState
- type BuildResult
- type Builder
- type CallbackDeclaration
- type CallbackEvent
- type CallbackPublisher
- type CredentialDeclaration
- type ExecutionStateStore
- type ExecutionStatus
- type GuardrailDeclaration
- type GuardrailFactory
- type HTTPCallbackPublisher
- type InMemoryExecutionStateStore
- func (s *InMemoryExecutionStateStore) Clear(_ context.Context, sessionID string) error
- func (s *InMemoryExecutionStateStore) Load(_ context.Context, sessionID string) (WorkflowExecutionState, bool, error)
- func (s *InMemoryExecutionStateStore) Save(_ context.Context, state WorkflowExecutionState) error
- type MCPDeclaration
- type ModelDeclaration
- type OutputTypeDeclaration
- type OutputTypeFactory
- type ReasoningDeclaration
- type RunSummary
- type RunnerService
- type SessionDeclaration
- type SessionFactory
- type StdoutCallbackPublisher
- type ToolDeclaration
- type ToolFactory
- type ToolFactoryEnv
- type WorkflowDeclaration
- type WorkflowExecutionState
- type WorkflowRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateWorkflowRequest ¶
func ValidateWorkflowRequest(req WorkflowRequest) error
ValidateWorkflowRequest performs structural validation and returns an error describing the first issue encountered.
Types ¶
type AgentDeclaration ¶
type AgentDeclaration struct {
Name string `json:"name"`
DisplayName string `json:"display_name,omitempty"`
Instructions string `json:"instructions,omitempty"`
PromptID string `json:"prompt_id,omitempty"`
Model *ModelDeclaration `json:"model,omitempty"`
Handoffs []string `json:"handoff,omitempty"`
AgentTools []AgentToolReference `json:"agent_tools,omitempty"`
Tools []ToolDeclaration `json:"tools,omitempty"`
MCPServers []MCPDeclaration `json:"mcp,omitempty"`
InputGuardrails []GuardrailDeclaration `json:"input_guardrails,omitempty"`
OutputGuardrails []GuardrailDeclaration `json:"output_guardrails,omitempty"`
OutputType *OutputTypeDeclaration `json:"output_type,omitempty"`
HandoffDescription string `json:"handoff_description,omitempty"`
Annotations map[string]any `json:"annotations,omitempty"`
}
AgentDeclaration captures the configuration of a single agent.
type AgentToolReference ¶
type AgentToolReference struct {
AgentName string `json:"agent_name"`
ToolName string `json:"tool_name,omitempty"`
Description string `json:"description,omitempty"`
}
AgentToolReference allows referencing another agent as a tool.
type ApprovalRequestState ¶
type BuildResult ¶
type BuildResult struct {
StartingAgent *agents.Agent
AgentMap map[string]*agents.Agent
Runner agents.Runner
Session memory.Session
WorkflowName string
TraceMetadata map[string]any
}
BuildResult contains the artifacts required to execute a workflow.
type Builder ¶
type Builder struct {
ToolFactories map[string]ToolFactory
OutputTypeFactories map[string]OutputTypeFactory
SessionFactory SessionFactory
}
Builder converts declarative workflow payloads into executable SDK primitives.
func NewDefaultBuilder ¶
func NewDefaultBuilder() *Builder
NewDefaultBuilder returns a Builder with the builtin registries initialized.
func (*Builder) Build ¶
func (b *Builder) Build(ctx context.Context, req WorkflowRequest) (*BuildResult, error)
Build constructs agents, run configuration, and session resources from the request.
type CallbackDeclaration ¶
type CallbackDeclaration struct {
Target string `json:"target"`
Mode string `json:"mode,omitempty"`
}
CallbackDeclaration describes how streaming events should be published.
func (*CallbackDeclaration) UnmarshalJSON ¶
func (c *CallbackDeclaration) UnmarshalJSON(data []byte) error
UnmarshalJSON allows callback to be provided as string or object.
func (*CallbackDeclaration) Validate ¶
func (c *CallbackDeclaration) Validate() error
Validate performs shallow validation of the callback declaration.
type CallbackEvent ¶
type CallbackEvent struct {
Type string `json:"type"`
Timestamp time.Time `json:"timestamp"`
Payload any `json:"payload,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
CallbackEvent describes an update emitted during a workflow run.
type CallbackPublisher ¶
type CallbackPublisher interface {
Publish(ctx context.Context, event CallbackEvent) error
}
CallbackPublisher publishes streaming events to an external sink.
type CredentialDeclaration ¶
type CredentialDeclaration struct {
UserID string `json:"user_id"`
AccountID string `json:"account_id"`
Capabilities []string `json:"capabilities,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
CredentialDeclaration contains minimal identity data used for validation / logging.
type ExecutionStateStore ¶
type ExecutionStatus ¶
type ExecutionStatus string
const ( ExecutionStatusIdle ExecutionStatus = "idle" ExecutionStatusRunning ExecutionStatus = "running" ExecutionStatusWaitingApproval ExecutionStatus = "waiting_approval" ExecutionStatusCompleted ExecutionStatus = "completed" ExecutionStatusFailed ExecutionStatus = "failed" )
type GuardrailDeclaration ¶
type GuardrailDeclaration struct {
Name string `json:"name"`
Config map[string]any `json:"config,omitempty"`
Target string `json:"target,omitempty"`
}
GuardrailDeclaration references a reusable guardrail preset.
type GuardrailFactory ¶
type GuardrailFactory func(ctx context.Context, decl GuardrailDeclaration) (agents.InputGuardrail, error)
GuardrailFactory is a placeholder for future guardrail registry integration.
type HTTPCallbackPublisher ¶
type HTTPCallbackPublisher struct {
URL string
// contains filtered or unexported fields
}
HTTPCallbackPublisher POSTs events to a configured endpoint as JSON.
func NewHTTPCallbackPublisher ¶
func NewHTTPCallbackPublisher(url string, client *http.Client) *HTTPCallbackPublisher
NewHTTPCallbackPublisher constructs an HTTP publisher with an optional custom client.
func (*HTTPCallbackPublisher) Publish ¶
func (p *HTTPCallbackPublisher) Publish(ctx context.Context, event CallbackEvent) error
type InMemoryExecutionStateStore ¶
type InMemoryExecutionStateStore struct {
// contains filtered or unexported fields
}
func NewInMemoryExecutionStateStore ¶
func NewInMemoryExecutionStateStore() *InMemoryExecutionStateStore
func (*InMemoryExecutionStateStore) Clear ¶
func (s *InMemoryExecutionStateStore) Clear(_ context.Context, sessionID string) error
func (*InMemoryExecutionStateStore) Load ¶
func (s *InMemoryExecutionStateStore) Load(_ context.Context, sessionID string) (WorkflowExecutionState, bool, error)
func (*InMemoryExecutionStateStore) Save ¶
func (s *InMemoryExecutionStateStore) Save(_ context.Context, state WorkflowExecutionState) error
type MCPDeclaration ¶
type MCPDeclaration struct {
Type string `json:"type,omitempty"`
ServerLabel string `json:"server_label,omitempty"`
Address string `json:"address"`
RequireApproval string `json:"require_approval,omitempty"`
Additional map[string]any `json:"additional,omitempty"`
}
MCPDeclaration configures hosted or stdio MCP servers.
type ModelDeclaration ¶
type ModelDeclaration struct {
Provider string `json:"provider,omitempty"`
Model string `json:"model"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
MaxTokens *int64 `json:"max_tokens,omitempty"`
Reasoning *ReasoningDeclaration `json:"reasoning,omitempty"`
Verbosity string `json:"verbosity,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
ExtraHeaders map[string]string `json:"extra_headers,omitempty"`
ExtraQuery map[string]string `json:"extra_query,omitempty"`
ToolChoice string `json:"tool_choice,omitempty"`
}
ModelDeclaration indicates which model/provider to use and optional settings.
type OutputTypeDeclaration ¶
type OutputTypeDeclaration struct {
Name string `json:"name"`
Strict bool `json:"strict,omitempty"`
Schema map[string]any `json:"schema,omitempty"`
}
OutputTypeDeclaration describes the expected structured output.
type OutputTypeFactory ¶
type OutputTypeFactory func(ctx context.Context, decl OutputTypeDeclaration) (agents.OutputTypeInterface, error)
OutputTypeFactory produces custom output type implementations.
type ReasoningDeclaration ¶
type ReasoningDeclaration struct {
Effort string `json:"effort,omitempty"`
Summary string `json:"summary,omitempty"`
}
ReasoningDeclaration mirrors the subset of OpenAI reasoning parameters we support.
type RunSummary ¶
type RunSummary struct {
WorkflowName string `json:"workflow_name"`
SessionID string `json:"session_id"`
FinalOutput any `json:"final_output"`
NewItems []agents.RunItem `json:"-"`
LastResponseID string `json:"last_response_id"`
Error error `json:"error,omitempty"`
}
RunSummary holds metadata about a completed run.
type RunnerService ¶
type RunnerService struct {
Builder *Builder
CallbackFactory func(ctx context.Context, decl CallbackDeclaration) (CallbackPublisher, error)
StateStore ExecutionStateStore
}
RunnerService orchestrates building and executing workflow requests.
func NewRunnerService ¶
func NewRunnerService(builder *Builder) *RunnerService
NewRunnerService constructs a RunnerService with sensible defaults.
func (*RunnerService) Execute ¶
func (s *RunnerService) Execute(ctx context.Context, req WorkflowRequest) (*asynctask.Task[RunSummary], error)
Execute validates, builds, and runs the workflow asynchronously.
type SessionDeclaration ¶
type SessionDeclaration struct {
SessionID string `json:"session_id"`
HistorySize int `json:"history_size,omitempty"`
MaxTurns int `json:"max_turns,omitempty"`
Credentials CredentialDeclaration `json:"credentials"`
}
SessionDeclaration carries caller-provided state and execution limits.
type SessionFactory ¶
SessionFactory allocates or loads a conversational session.
func NewSQLiteSessionFactory ¶
func NewSQLiteSessionFactory(baseDir string) SessionFactory
NewSQLiteSessionFactory stores sessions on-disk inside baseDir (created if needed).
type StdoutCallbackPublisher ¶
type StdoutCallbackPublisher struct{}
StdoutCallbackPublisher prints events to stdout (useful for local testing).
func (StdoutCallbackPublisher) Publish ¶
func (StdoutCallbackPublisher) Publish(_ context.Context, event CallbackEvent) error
type ToolDeclaration ¶
type ToolDeclaration struct {
Type string `json:"type"`
Name string `json:"name,omitempty"`
Config map[string]any `json:"config,omitempty"`
}
ToolDeclaration represents a tool that should be attached to an agent.
type ToolFactory ¶
type ToolFactory func(ctx context.Context, decl ToolDeclaration, env ToolFactoryEnv) (agents.Tool, error)
ToolFactory creates an agents.Tool from the declaration.
type ToolFactoryEnv ¶
ToolFactoryEnv provides context when constructing tools.
type WorkflowDeclaration ¶
type WorkflowDeclaration struct {
Name string `json:"name"`
StartingAgent string `json:"starting_agent"`
Agents []AgentDeclaration `json:"agents"`
Metadata map[string]any `json:"metadata,omitempty"`
}
WorkflowDeclaration defines the agent graph that should be executed.
type WorkflowExecutionState ¶
type WorkflowExecutionState struct {
SessionID string `json:"session_id"`
WorkflowName string `json:"workflow_name"`
Status ExecutionStatus `json:"status"`
LastAgent string `json:"last_agent"`
LastResponseID string `json:"last_response_id"`
LastQuery string `json:"last_query"`
LastError string `json:"last_error"`
PendingApprovals []ApprovalRequestState `json:"pending_approvals"`
FinalOutput any `json:"final_output,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
type WorkflowRequest ¶
type WorkflowRequest struct {
Query string `json:"query"`
Session SessionDeclaration `json:"session"`
Callback CallbackDeclaration `json:"callback"`
Workflow WorkflowDeclaration `json:"workflow"`
Metadata map[string]any `json:"metadata,omitempty"`
Context map[string]any `json:"context,omitempty"`
}
WorkflowRequest represents the top-level payload describing a workflow run.