adapter

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

ABOUTME: Bootstrap functions for creating mux agents in hex. ABOUTME: Handles root agent and subagent creation with proper tool filtering.

ABOUTME: Package adapter provides adapters for integrating hex with mux. ABOUTME: This package bridges hex's existing tools and orchestrator with mux's agent system.

ABOUTME: LLM client wrapper that injects extended thinking config into requests ABOUTME: Enables deep reasoning for complex tasks without modifying the mux orchestrator

ABOUTME: Adapter that wraps hex tools to implement mux's tool.Tool interface. ABOUTME: Allows hex's existing tools to work with mux's orchestrator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdaptAll

func AdaptAll(hexTools []tools.Tool) []muxtool.Tool

AdaptAll wraps multiple hex tools for use with mux.

func AdaptTool

func AdaptTool(t tools.Tool) muxtool.Tool

AdaptTool wraps a hex tool for use with mux.

func IsSubagent

func IsSubagent() bool

IsSubagent returns true if this process is running as a subagent.

func NewRootAgent

func NewRootAgent(cfg Config) *agent.Agent

NewRootAgent creates a root agent with full tool access.

func NewSubagent

func NewSubagent(cfg Config) *agent.Agent

NewSubagent creates a subagent with filtered tool access based on env vars.

func NewSubagentWithClient added in v1.10.0

func NewSubagentWithClient(cfg Config, llmClient llm.Client, agentID string) *agent.Agent

NewSubagentWithClient creates a subagent with an existing LLM client. This is useful for in-process subagent execution where we want to share/reuse the client.

Types

type AgentRunner added in v1.10.0

type AgentRunner struct {
	LLMClient    llm.Client          // LLM client for agent communication
	ToolFactory  func() []tools.Tool // Factory to create fresh tool instances
	ApprovalFunc func(ctx context.Context, toolName string, params map[string]any) (bool, error)
}

AgentRunner implements the tools.MuxAgentRunner interface. It creates and runs mux agents for in-process subagent execution.

func NewAgentRunner added in v1.10.0

func NewAgentRunner(llmClient llm.Client, toolFactory func() []tools.Tool) *AgentRunner

NewAgentRunner creates a new AgentRunner for executing mux agents.

func (*AgentRunner) RunAgent added in v1.10.0

func (r *AgentRunner) RunAgent(ctx context.Context, agentID, prompt, systemPrompt string, allowedTools []string) (string, error)

RunAgent executes a subagent with the given configuration and returns the output.

type ApprovalFunc

type ApprovalFunc func(ctx context.Context, toolName string, params map[string]any) (bool, error)

ApprovalFunc is called when a tool requires approval before execution. Returns true to approve, false to deny. Error indicates approval check failed.

type Config

type Config struct {
	APIKey       string
	Model        string
	SystemPrompt string
	HexTools     []tools.Tool
	ApprovalFunc ApprovalFunc      // Optional: if nil, tools requiring approval will fail
	HookManager  *muxhooks.Manager // Optional: mux hook manager for lifecycle events
	LLMClient    llm.Client        // Optional: pre-configured LLM client (overrides APIKey/Model)
}

Config holds configuration for creating an agent.

type ThinkingClient added in v1.12.0

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

ThinkingClient wraps an LLM client and injects ThinkingConfig into every request.

func NewThinkingClient added in v1.12.0

func NewThinkingClient(inner llm.Client, budgetTokens int) *ThinkingClient

NewThinkingClient creates a client wrapper that enables extended thinking.

func (*ThinkingClient) CreateMessage added in v1.12.0

func (c *ThinkingClient) CreateMessage(ctx context.Context, req *llm.Request) (*llm.Response, error)

CreateMessage injects thinking config and delegates to the inner client.

func (*ThinkingClient) CreateMessageStream added in v1.12.0

func (c *ThinkingClient) CreateMessageStream(ctx context.Context, req *llm.Request) (<-chan llm.StreamEvent, error)

CreateMessageStream injects thinking config and delegates to the inner client.

Jump to

Keyboard shortcuts

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