tasks

package
v0.1.45 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AgentPermissionReadOnly = "read_only"
	AgentPermissionAsk      = "ask"
	AgentPermissionAuto     = "auto"
	AgentPermissionTrusted  = "trusted"

	AgentIsolationNone     = "none"
	AgentIsolationWorktree = "worktree"
)
View Source
const (
	CapabilityWorkspaceRead  = "workspace.read"
	CapabilityWorkspaceWrite = "workspace.write"
	CapabilityShellRead      = "shell.read"
	CapabilityShellRun       = "shell.run"
	CapabilityTerminalWrite  = "terminal.write"
	CapabilityWebSearch      = "web.search"
	CapabilityWebFetch       = "web.fetch"
	CapabilityMCPRead        = "mcp.read"
)
View Source
const (
	MaxParallelPrompts    = 8
	DefaultMaxTokens      = 800
	DefaultMaxToolIters   = 12
	DefaultSummaryMaxChar = 8 * 1024
)
View Source
const AgentDefinitionFileExt = ".md"

Variables

This section is empty.

Functions

func AllowedAgentToolNames added in v0.1.34

func AllowedAgentToolNames(parent *core.ToolRegistry, capabilities []string, permissionMode string) ([]string, error)

func AllowedAgentToolNamesForMCPServers added in v0.1.34

func AllowedAgentToolNamesForMCPServers(parent *core.ToolRegistry, capabilities []string, permissionMode string, mcpServers []string, disallowed ...[]string) ([]string, error)

func AllowedCapabilityToolNames added in v0.1.30

func AllowedCapabilityToolNames(parent *core.ToolRegistry, capabilities []string) ([]string, error)

func BuildAgentRegistry added in v0.1.34

func BuildAgentRegistry(parent *core.ToolRegistry, capabilities []string, permissionMode string) (*core.ToolRegistry, error)

func BuildAgentRegistryForMCPServers added in v0.1.34

func BuildAgentRegistryForMCPServers(parent *core.ToolRegistry, capabilities []string, permissionMode string, mcpServers []string, disallowed ...[]string) (*core.ToolRegistry, error)

func BuildCapabilityRegistry added in v0.1.30

func BuildCapabilityRegistry(parent *core.ToolRegistry, capabilities []string) (*core.ToolRegistry, error)

func BuildReadOnlyRegistry

func BuildReadOnlyRegistry(parent *core.ToolRegistry) (*core.ToolRegistry, error)

func CapabilityTools added in v0.1.30

func CapabilityTools(parent *core.ToolRegistry, capabilities []string) ([]core.Tool, error)

func CapabilityToolsForPermission added in v0.1.34

func CapabilityToolsForPermission(parent *core.ToolRegistry, capabilities []string, permissionMode string, disallowed ...[]string) ([]core.Tool, error)

func NewTools

func NewTools(r *Runner) []core.Tool

func ReadOnlyTools

func ReadOnlyTools(parent *core.ToolRegistry) []core.Tool

func ResolveAgentHooks added in v0.1.34

func ResolveAgentHooks(def AgentDefinition) ([]agent.ResolvedHook, error)

ResolveAgentHooks converts durable agent-definition hook metadata into the concrete hook runner used by child agents. It accepts Claude Code style command, shell, prompt, http, and agent hooks; runtime execution is handled by the agent hook runner plus task-runner model executors.

func ValidAgentDefinitionName added in v0.1.34

func ValidAgentDefinitionName(name string) bool

Types

type AgentDefinition added in v0.1.33

type AgentDefinition struct {
	Name            string                `json:"name,omitempty"`
	Description     string                `json:"description,omitempty"`
	WhenToUse       string                `json:"whenToUse,omitempty"`
	Prompt          string                `json:"prompt,omitempty"`
	Tools           []string              `json:"tools,omitempty"`
	DisallowedTools []string              `json:"disallowedTools,omitempty"`
	Skills          []string              `json:"skills,omitempty"`
	MCPServers      []string              `json:"mcpServers,omitempty"`
	Hooks           any                   `json:"hooks,omitempty"`
	Model           string                `json:"model,omitempty"`
	Effort          string                `json:"effort,omitempty"`
	PermissionMode  string                `json:"permissionMode,omitempty"`
	MaxToolIters    int                   `json:"maxToolIters,omitempty"`
	MaxToolCalls    int                   `json:"maxToolCalls,omitempty"`
	MaxTurns        int                   `json:"maxTurns,omitempty"`
	InitialPrompt   string                `json:"initialPrompt,omitempty"`
	Memory          string                `json:"memory,omitempty"`
	Background      bool                  `json:"background,omitempty"`
	Isolation       string                `json:"isolation,omitempty"`
	Generation      AgentGenerationConfig `json:"generation,omitempty"`
}

AgentDefinition is the durable contract for child-agent execution. Workflow agent calls and spawn_subagent requests should converge here before tools, model, and runtime limits are resolved.

type AgentDefinitionLibrary added in v0.1.34

type AgentDefinitionLibrary struct {
	Roots       []AgentDefinitionRoot
	Definitions []AgentDefinition
}

func NewAgentDefinitionLibrary added in v0.1.34

func NewAgentDefinitionLibrary(workspaceRoot string) *AgentDefinitionLibrary

func NewAgentDefinitionLibraryWithDefinitions added in v0.1.34

func NewAgentDefinitionLibraryWithDefinitions(workspaceRoot string, definitions []AgentDefinition) *AgentDefinitionLibrary

func NewAgentDefinitionLibraryWithRoots added in v0.1.34

func NewAgentDefinitionLibraryWithRoots(roots []AgentDefinitionRoot) *AgentDefinitionLibrary

func (*AgentDefinitionLibrary) List added in v0.1.34

func (*AgentDefinitionLibrary) Resolve added in v0.1.34

type AgentDefinitionRoot added in v0.1.34

type AgentDefinitionRoot struct {
	Path   string
	Source string
	Rank   int
}

type AgentGenerationConfig added in v0.1.35

type AgentGenerationConfig struct {
	AssistantPrefix  string `json:"assistantPrefix,omitempty"`
	PrefixCompletion bool   `json:"prefixCompletion,omitempty"`
}

type AgentRuntimeConfig added in v0.1.34

type AgentRuntimeConfig struct {
	Definition        AgentDefinition
	Model             string
	Effort            string
	MaxToolIters      int
	MaxToolCalls      int
	MaxTurns          int
	ToolSelectors     []string
	DisallowedTools   []string
	MCPServers        []string
	Hooks             []agent.ResolvedHook
	PermissionProfile string
	Isolation         string
	Skills            []string
	InitialPrompt     string
	Memory            string
	Generation        AgentGenerationConfig
}

func ResolveAgentRuntimeConfig added in v0.1.34

func ResolveAgentRuntimeConfig(req SpawnSubagentRequest, defaults RunnerDefaults) (AgentRuntimeConfig, error)

func ResolveAgentRuntimeConfigWithLibrary added in v0.1.34

func ResolveAgentRuntimeConfigWithLibrary(req SpawnSubagentRequest, defaults RunnerDefaults, library *AgentDefinitionLibrary) (AgentRuntimeConfig, error)

type ParallelReasonRequest

type ParallelReasonRequest struct {
	Prompts   []string `json:"prompts"`
	Model     string   `json:"model,omitempty"`
	MaxTokens int      `json:"max_tokens,omitempty"`
}

type ParallelReasonResponse

type ParallelReasonResponse struct {
	Model   string                 `json:"model"`
	Results []ParallelReasonResult `json:"results"`
	Usage   llm.Usage              `json:"usage"`
}

type ParallelReasonResult

type ParallelReasonResult struct {
	Index  int       `json:"index"`
	Prompt string    `json:"prompt"`
	Output string    `json:"output,omitempty"`
	Error  string    `json:"error,omitempty"`
	Usage  llm.Usage `json:"usage,omitempty"`
}

type ProviderFactory

type ProviderFactory func(model string, maxTokens int) (llm.Provider, error)

type ProviderFactoryWithOptions added in v0.1.34

type ProviderFactoryWithOptions func(ProviderRequest) (llm.Provider, error)

type ProviderRequest added in v0.1.34

type ProviderRequest struct {
	Model     string
	MaxTokens int
	Effort    string
}

type Runner

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

func NewRunner

func NewRunner(cfg RunnerConfig) *Runner

func (*Runner) AllowedSubagentTools added in v0.1.30

func (r *Runner) AllowedSubagentTools(req SpawnSubagentRequest) ([]string, error)

func (*Runner) CancelBackgroundSubagent added in v0.1.34

func (r *Runner) CancelBackgroundSubagent(sessionID string) (session.SessionMeta, bool, error)

func (*Runner) ParallelReason

func (*Runner) SpawnSubagent

func (r *Runner) SpawnSubagent(ctx context.Context, req SpawnSubagentRequest) (SpawnSubagentResponse, error)

func (*Runner) SpawnSubagentWithProgress

func (r *Runner) SpawnSubagentWithProgress(ctx context.Context, req SpawnSubagentRequest, progress func(core.ToolProgress)) (SpawnSubagentResponse, error)

func (*Runner) SubagentStatus added in v0.1.34

func (r *Runner) SubagentStatus(sessionID string) (session.SessionMeta, error)

type RunnerConfig

type RunnerConfig struct {
	ProviderFactory            ProviderFactory
	ProviderFactoryWithOptions ProviderFactoryWithOptions
	ParentTools                *core.ToolRegistry
	WorkspaceTools             WorkspaceToolRegistryFactory
	AgentDefinitions           *AgentDefinitionLibrary
	ParentPolicy               policy.ToolPolicy
	MessageStore               store.MessageStore
	SessionsDir                string
	ParentSessionID            string
	ParentSessionIDFunc        func() string
	WorkspaceRoot              string
	MemoryEnabled              bool
	MemoryMaxChars             int
	MemoryFileOrder            []string
	SkillsDisabled             []string
	ExtraSkills                []*skills.Skill
	AutoCompact                bool
	AutoCompactThreshold       float64
	DefaultModel               string
	DefaultMaxTokens           int
	DefaultMaxToolIters        int
	SummaryMaxChars            int
	UsageLogPath               string
	ApprovalFunc               policy.ApprovalFunc
}

type RunnerDefaults added in v0.1.34

type RunnerDefaults struct {
	Model        string
	MaxToolIters int
	MaxToolCalls int
}

type SpawnSubagentError

type SpawnSubagentError struct {
	SessionID string
	Code      string
	Message   string
	Err       error
}

func (*SpawnSubagentError) Error

func (e *SpawnSubagentError) Error() string

func (*SpawnSubagentError) Unwrap

func (e *SpawnSubagentError) Unwrap() error

type SpawnSubagentRequest

type SpawnSubagentRequest struct {
	Task              string          `json:"task"`
	Role              string          `json:"role,omitempty"`
	Agent             AgentDefinition `json:"agent,omitempty"`
	Model             string          `json:"model,omitempty"`
	MaxToolIters      int             `json:"max_tool_iters,omitempty"`
	MaxToolCalls      int             `json:"max_tool_calls,omitempty"`
	Tools             []string        `json:"tools,omitempty"`
	OutputSchema      map[string]any  `json:"output_schema,omitempty"`
	ParentToolCallID  string          `json:"-"`
	WorkflowRunID     string          `json:"-"`
	WorkflowName      string          `json:"-"`
	WorkflowPhase     string          `json:"-"`
	WorkflowTaskID    string          `json:"-"`
	WorkflowTaskLabel string          `json:"-"`
}

type SpawnSubagentResponse

type SpawnSubagentResponse struct {
	SessionID         string         `json:"session_id"`
	Role              string         `json:"role"`
	Model             string         `json:"model"`
	PermissionProfile string         `json:"permission_profile"`
	Status            string         `json:"status"`
	Summary           string         `json:"summary"`
	StructuredResult  any            `json:"structured_result,omitempty"`
	Error             string         `json:"error,omitempty"`
	Truncated         bool           `json:"truncated"`
	ToolCalls         []string       `json:"tool_calls,omitempty"`
	RequestedTools    []string       `json:"requested_tools,omitempty"`
	ResolvedTools     []string       `json:"resolved_tools,omitempty"`
	ToolMode          string         `json:"tool_mode,omitempty"`
	Usage             llm.Usage      `json:"usage,omitempty"`
	SubagentBudget    SubagentBudget `json:"subagent_budget,omitempty"`
	DurationMS        int64          `json:"duration_ms"`
	CompletedAt       string         `json:"completed_at"`
}

type SubagentBudget added in v0.1.38

type SubagentBudget struct {
	SpawnCount  int    `json:"spawn_count"`
	TotalTokens int    `json:"total_tokens"`
	Hint        string `json:"hint,omitempty"`
}

type ToolWorkspace added in v0.1.34

type ToolWorkspace struct {
	WorkspaceRoot      string
	WorktreeRoot       string
	OriginalWorkspace  string
	WorktreeName       string
	WorktreeBranch     string
	OriginalBranch     string
	OriginalHeadCommit string
}

type WorkspaceToolRegistryFactory added in v0.1.34

type WorkspaceToolRegistryFactory func(ToolWorkspace) (*core.ToolRegistry, error)

Jump to

Keyboard shortcuts

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