tools

package
v0.0.0-...-6c5c7c9 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package tools provides the tool system for AI agents. It follows patterns from pi-agent and clawdbot for tool registration, execution, and policy enforcement.

Index

Constants

View Source
const (
	GroupSearch    = toolpolicy.GroupSearch
	GroupCalc      = toolpolicy.GroupCalc
	GroupBuilder   = toolpolicy.GroupBuilder
	GroupMessaging = toolpolicy.GroupMessaging
	GroupSessions  = toolpolicy.GroupSessions
	GroupMemory    = toolpolicy.GroupMemory
	GroupWeb       = toolpolicy.GroupWeb
	GroupMedia     = toolpolicy.GroupMedia
	GroupStatus    = toolpolicy.GroupStatus
	GroupOpenClaw  = toolpolicy.GroupOpenClaw
	GroupFS        = toolpolicy.GroupFS
	GroupNexus     = toolpolicy.GroupNexus
)

Tool group constants for policy composition (OpenClaw-style shorthands).

Variables

View Source
var (
	MessageTool = &Tool{
		Tool: mcp.Tool{
			Name:        toolspec.MessageName,
			Description: toolspec.MessageDescription,
			Annotations: &mcp.ToolAnnotations{Title: "Message"},
			InputSchema: toolspec.MessageSchema(),
		},
		Type:  ToolTypeBuiltin,
		Group: GroupMessaging,
	}
	WebFetchTool = &Tool{
		Tool: mcp.Tool{
			Name:        toolspec.WebFetchName,
			Description: toolspec.WebFetchDescription,
			Annotations: &mcp.ToolAnnotations{Title: "Web Fetch"},
			InputSchema: toolspec.WebFetchSchema(),
		},
		Type:  ToolTypeBuiltin,
		Group: GroupWeb,
	}
	SessionStatusTool = &Tool{
		Tool: mcp.Tool{
			Name:        toolspec.SessionStatusName,
			Description: toolspec.SessionStatusDescription,
			Annotations: &mcp.ToolAnnotations{Title: "Session Status"},
			InputSchema: toolspec.SessionStatusSchema(),
		},
		Type:  ToolTypeBuiltin,
		Group: GroupStatus,
	}
	MemorySearchTool = &Tool{
		Tool: mcp.Tool{
			Name:        toolspec.MemorySearchName,
			Description: toolspec.MemorySearchDescription,
			Annotations: &mcp.ToolAnnotations{Title: "Memory Search"},
			InputSchema: toolspec.MemorySearchSchema(),
		},
		Type:  ToolTypeBuiltin,
		Group: GroupMemory,
	}
	MemoryGetTool = &Tool{
		Tool: mcp.Tool{
			Name:        toolspec.MemoryGetName,
			Description: toolspec.MemoryGetDescription,
			Annotations: &mcp.ToolAnnotations{Title: "Memory Get"},
			InputSchema: toolspec.MemoryGetSchema(),
		},
		Type:  ToolTypeBuiltin,
		Group: GroupMemory,
	}
	ImageTool = &Tool{
		Tool: mcp.Tool{
			Name:        toolspec.ImageName,
			Description: toolspec.ImageDescription,
			Annotations: &mcp.ToolAnnotations{Title: "Image"},
			InputSchema: toolspec.ImageSchema(),
		},
		Type:  ToolTypeBuiltin,
		Group: GroupMedia,
	}
	ImageGenerateTool = &Tool{
		Tool: mcp.Tool{
			Name:        toolspec.ImageGenerateName,
			Description: toolspec.ImageGenerateDescription,
			Annotations: &mcp.ToolAnnotations{Title: "Image Generate"},
			InputSchema: toolspec.ImageGenerateSchema(),
		},
		Type:  ToolTypeBuiltin,
		Group: GroupMedia,
	}
	TTSTool = &Tool{
		Tool: mcp.Tool{
			Name:        toolspec.TTSName,
			Description: toolspec.TTSDescription,
			Annotations: &mcp.ToolAnnotations{Title: "TTS"},
			InputSchema: toolspec.TTSSchema(),
		},
		Type:  ToolTypeBuiltin,
		Group: GroupMedia,
	}
	GravatarFetchTool = &Tool{
		Tool: mcp.Tool{
			Name:        toolspec.GravatarFetchName,
			Description: toolspec.GravatarFetchDescription,
			Annotations: &mcp.ToolAnnotations{Title: "Gravatar Fetch"},
			InputSchema: toolspec.GravatarFetchSchema(),
		},
		Type:  ToolTypeBuiltin,
		Group: GroupOpenClaw,
	}
	GravatarSetTool = &Tool{
		Tool: mcp.Tool{
			Name:        toolspec.GravatarSetName,
			Description: toolspec.GravatarSetDescription,
			Annotations: &mcp.ToolAnnotations{Title: "Gravatar Set"},
			InputSchema: toolspec.GravatarSetSchema(),
		},
		Type:  ToolTypeBuiltin,
		Group: GroupBuilder,
	}
)
View Source
var (
	ReadTool = &Tool{
		Tool: mcp.Tool{
			Name:        toolspec.ReadName,
			Description: toolspec.ReadDescription,
			Annotations: &mcp.ToolAnnotations{Title: "Read"},
			InputSchema: toolspec.ReadSchema(),
		},
		Type:    ToolTypeBuiltin,
		Group:   GroupFS,
		Execute: execUnavailable(toolspec.ReadName),
	}
	WriteTool = &Tool{
		Tool: mcp.Tool{
			Name:        toolspec.WriteName,
			Description: toolspec.WriteDescription,
			Annotations: &mcp.ToolAnnotations{Title: "Write"},
			InputSchema: toolspec.WriteSchema(),
		},
		Type:    ToolTypeBuiltin,
		Group:   GroupFS,
		Execute: execUnavailable(toolspec.WriteName),
	}
	EditTool = &Tool{
		Tool: mcp.Tool{
			Name:        toolspec.EditName,
			Description: toolspec.EditDescription,
			Annotations: &mcp.ToolAnnotations{Title: "Edit"},
			InputSchema: toolspec.EditSchema(),
		},
		Type:    ToolTypeBuiltin,
		Group:   GroupFS,
		Execute: execUnavailable(toolspec.EditName),
	}
)
View Source
var AgentsListTool = &Tool{
	Tool: mcp.Tool{
		Name:        "agents_list",
		Description: "List agent ids you can target with sessions_spawn (based on allowlists).",
		Annotations: &mcp.ToolAnnotations{Title: "Agents List"},
		InputSchema: map[string]any{
			"type":       "object",
			"properties": map[string]any{},
		},
	},
	Type:  ToolTypeBuiltin,
	Group: GroupSessions,
}

AgentsListTool lists agent ids allowed for sessions_spawn.

View Source
var ApplyPatchTool = &Tool{
	Tool: mcp.Tool{
		Name:        toolspec.ApplyPatchName,
		Description: toolspec.ApplyPatchDescription,
		Annotations: &mcp.ToolAnnotations{Title: "apply_patch"},
		InputSchema: toolspec.ApplyPatchSchema(),
	},
	Type:    ToolTypeBuiltin,
	Group:   GroupFS,
	Execute: execUnavailable(toolspec.ApplyPatchName),
}
View Source
var BeeperDocsTool = &Tool{
	Tool: mcp.Tool{
		Name:        toolspec.BeeperDocsName,
		Description: toolspec.BeeperDocsDescription,
		Annotations: &mcp.ToolAnnotations{Title: "Beeper Docs"},
		InputSchema: toolspec.BeeperDocsSchema(),
	},
	Type:    ToolTypeBuiltin,
	Group:   GroupWeb,
	Execute: executeBeeperDocsPlaceholder,
}

BeeperDocsTool is the Beeper help documentation search tool.

View Source
var BeeperSendFeedbackTool = &Tool{
	Tool: mcp.Tool{
		Name:        toolspec.BeeperSendFeedbackName,
		Description: toolspec.BeeperSendFeedbackDescription,
		Annotations: &mcp.ToolAnnotations{Title: "Beeper Send Feedback"},
		InputSchema: toolspec.BeeperSendFeedbackSchema(),
	},
	Type:    ToolTypeBuiltin,
	Group:   GroupWeb,
	Execute: executeBeeperSendFeedbackPlaceholder,
}

BeeperSendFeedbackTool is the Beeper feedback submission tool.

View Source
var Calculator = &Tool{
	Tool: mcp.Tool{
		Name:        toolspec.CalculatorName,
		Description: toolspec.CalculatorDescription,
		Annotations: &mcp.ToolAnnotations{Title: "Calculator"},
		InputSchema: toolspec.CalculatorSchema(),
	},
	Type:    ToolTypeBuiltin,
	Group:   GroupCalc,
	Execute: executeCalculator,
}

Calculator is the calculator tool definition.

View Source
var CreateAgentTool = &Tool{
	Tool: mcp.Tool{
		Name:        "create_agent",
		Description: "Create a new AI agent with custom configuration",
		Annotations: &mcp.ToolAnnotations{Title: "Create Agent"},
		InputSchema: map[string]any{
			"type": "object",
			"properties": map[string]any{
				"name": map[string]any{
					"type":        "string",
					"description": "Display name for the agent",
				},
				"description": map[string]any{
					"type":        "string",
					"description": "Brief description of what the agent does",
				},
				"model": map[string]any{
					"type":        "string",
					"description": "Model ID to use (e.g., 'anthropic/claude-sonnet-4.5'). Leave empty for default.",
				},
				"system_prompt": map[string]any{
					"type":        "string",
					"description": "Custom system prompt for the agent",
				},
				"tools": map[string]any{
					"type": "object",
					"properties": map[string]any{
						"profile": map[string]any{
							"type":        "string",
							"enum":        []string{"minimal", "coding", "messaging", "full", "boss"},
							"description": "Tool access profile (OpenClaw-style)",
						},
						"allow": map[string]any{
							"type":        "array",
							"items":       map[string]any{"type": "string"},
							"description": "Explicit tool allowlist (supports wildcards like 'web_*' or group:... shorthands)",
						},
						"alsoAllow": map[string]any{
							"type":        "array",
							"items":       map[string]any{"type": "string"},
							"description": "Additional allowlist entries merged into allow",
						},
						"deny": map[string]any{
							"type":        "array",
							"items":       map[string]any{"type": "string"},
							"description": "Explicit tool denylist (deny wins)",
						},
						"byProvider": map[string]any{
							"type":                 "object",
							"additionalProperties": map[string]any{"type": "object"},
							"description":          "Optional provider- or model-specific overrides keyed by provider or provider/model",
						},
					},
				},
				"subagents": map[string]any{
					"type": "object",
					"properties": map[string]any{
						"model": map[string]any{
							"type":        "string",
							"description": "Default model override for subagents spawned by this agent",
						},
						"allowAgents": map[string]any{
							"type":        "array",
							"items":       map[string]any{"type": "string"},
							"description": "Agent ids allowed for sessions_spawn (use \"*\" for any)",
						},
					},
				},
			},
			"required": []string{"name"},
		},
	},
	Type:  ToolTypeBuiltin,
	Group: GroupBuilder,
}

CreateAgent tool definition.

View Source
var CronTool = &Tool{
	Tool: mcp.Tool{
		Name:        toolspec.CronName,
		Description: toolspec.CronDescription,
		Annotations: &mcp.ToolAnnotations{Title: "Scheduler"},
		InputSchema: toolspec.CronSchema(),
	},
	Type:  ToolTypeBuiltin,
	Group: GroupOpenClaw,
}
View Source
var DeleteAgentTool = &Tool{
	Tool: mcp.Tool{
		Name:        "delete_agent",
		Description: "Delete a custom agent (preset agents cannot be deleted)",
		Annotations: &mcp.ToolAnnotations{Title: "Delete Agent"},
		InputSchema: map[string]any{
			"type": "object",
			"properties": map[string]any{
				"agent_id": map[string]any{
					"type":        "string",
					"description": "ID of the agent to delete",
				},
			},
			"required": []string{"agent_id"},
		},
	},
	Type:  ToolTypeBuiltin,
	Group: GroupBuilder,
}

DeleteAgentTool tool definition.

View Source
var EditAgentTool = &Tool{
	Tool: mcp.Tool{
		Name:        "edit_agent",
		Description: "Modify an existing custom agent's configuration",
		Annotations: &mcp.ToolAnnotations{Title: "Edit Agent"},
		InputSchema: map[string]any{
			"type": "object",
			"properties": map[string]any{
				"agent_id": map[string]any{
					"type":        "string",
					"description": "ID of the agent to edit",
				},
				"name": map[string]any{
					"type":        "string",
					"description": "New display name",
				},
				"description": map[string]any{
					"type":        "string",
					"description": "New description",
				},
				"model": map[string]any{
					"type":        "string",
					"description": "New model ID",
				},
				"system_prompt": map[string]any{
					"type":        "string",
					"description": "New system prompt",
				},
				"tools": map[string]any{
					"type": "object",
					"properties": map[string]any{
						"profile": map[string]any{
							"type":        "string",
							"enum":        []string{"minimal", "coding", "messaging", "full", "boss"},
							"description": "Tool access profile (OpenClaw-style)",
						},
						"allow": map[string]any{
							"type":        "array",
							"items":       map[string]any{"type": "string"},
							"description": "Explicit tool allowlist (supports wildcards like 'web_*' or group:... shorthands)",
						},
						"alsoAllow": map[string]any{
							"type":        "array",
							"items":       map[string]any{"type": "string"},
							"description": "Additional allowlist entries merged into allow",
						},
						"deny": map[string]any{
							"type":        "array",
							"items":       map[string]any{"type": "string"},
							"description": "Explicit tool denylist (deny wins)",
						},
						"byProvider": map[string]any{
							"type":                 "object",
							"additionalProperties": map[string]any{"type": "object"},
							"description":          "Optional provider- or model-specific overrides keyed by provider or provider/model",
						},
					},
				},
				"subagents": map[string]any{
					"type": "object",
					"properties": map[string]any{
						"model": map[string]any{
							"type":        "string",
							"description": "Default model override for subagents spawned by this agent",
						},
						"allowAgents": map[string]any{
							"type":        "array",
							"items":       map[string]any{"type": "string"},
							"description": "Agent ids allowed for sessions_spawn (use \"*\" for any)",
						},
					},
				},
			},
			"required": []string{"agent_id"},
		},
	},
	Type:  ToolTypeBuiltin,
	Group: GroupBuilder,
}

EditAgentTool tool definition.

View Source
var ForkAgentTool = &Tool{
	Tool: mcp.Tool{
		Name:        "fork_agent",
		Description: "Create a copy of an existing agent as a new custom agent",
		Annotations: &mcp.ToolAnnotations{Title: "Fork Agent"},
		InputSchema: map[string]any{
			"type": "object",
			"properties": map[string]any{
				"source_id": map[string]any{
					"type":        "string",
					"description": "ID of the agent to copy",
				},
				"new_name": map[string]any{
					"type":        "string",
					"description": "Name for the new agent (defaults to '[Original Name] (Fork)')",
				},
			},
			"required": []string{"source_id"},
		},
	},
	Type:  ToolTypeBuiltin,
	Group: GroupBuilder,
}

ForkAgentTool tool definition.

View Source
var ListAgentsTool = &Tool{
	Tool: mcp.Tool{
		Name:        "list_agents",
		Description: "List all available agents (both preset and custom)",
		Annotations: &mcp.ToolAnnotations{Title: "List Agents"},
		InputSchema: map[string]any{
			"type":       "object",
			"properties": map[string]any{},
		},
	},
	Type:  ToolTypeBuiltin,
	Group: GroupBuilder,
}

ListAgentsTool tool definition.

View Source
var ListModelsTool = &Tool{
	Tool: mcp.Tool{
		Name:        "list_models",
		Description: "List all available AI models",
		Annotations: &mcp.ToolAnnotations{Title: "List Models"},
		InputSchema: map[string]any{
			"type":       "object",
			"properties": map[string]any{},
		},
	},
	Type:  ToolTypeBuiltin,
	Group: GroupSessions,
}

ListModelsTool tool definition.

View Source
var ModifyRoomTool = &Tool{
	Tool: mcp.Tool{
		Name:        "modify_room",
		Description: "Modify an existing room's configuration",
		Annotations: &mcp.ToolAnnotations{Title: "Modify Room"},
		InputSchema: map[string]any{
			"type": "object",
			"properties": map[string]any{
				"room_id": map[string]any{
					"type":        "string",
					"description": "ID of the room to modify",
				},
				"name": map[string]any{
					"type":        "string",
					"description": "New display name for the room",
				},
				"agent_id": map[string]any{
					"type":        "string",
					"description": "New agent ID to assign to this room",
				},
				"system_prompt": map[string]any{
					"type":        "string",
					"description": "New system prompt override for this room",
				},
			},
			"required": []string{"room_id"},
		},
	},
	Type:  ToolTypeBuiltin,
	Group: GroupSessions,
}

ModifyRoomTool tool definition.

View Source
var RunInternalCommandTool = &Tool{
	Tool: mcp.Tool{
		Name:        "run_internal_command",
		Description: "Run an internal !ai command in a target room",
		Annotations: &mcp.ToolAnnotations{Title: "Run Internal Command"},
		InputSchema: map[string]any{
			"type": "object",
			"properties": map[string]any{
				"command": map[string]any{
					"type":        "string",
					"description": "The !ai command to run (with or without prefix)",
				},
				"room_id": map[string]any{
					"type":        "string",
					"description": "Optional target room ID (defaults to the current room)",
				},
			},
			"required": []string{"command"},
		},
	},
	Type:  ToolTypeBuiltin,
	Group: GroupBuilder,
}

RunInternalCommandTool tool definition.

View Source
var SessionsHistoryTool = &Tool{
	Tool: mcp.Tool{
		Name:        "sessions_history",
		Description: "Fetch message history for a session. Use the sessionKey from sessions_list.",
		Annotations: &mcp.ToolAnnotations{Title: "Session History"},
		InputSchema: map[string]any{
			"type": "object",
			"properties": map[string]any{
				"sessionKey": map[string]any{
					"type":        "string",
					"description": "Session identifier from sessions_list (preferred canonical target)",
				},
				"limit": map[string]any{
					"type":        "number",
					"description": "Maximum number of messages to return (default: 200)",
				},
				"includeTools": map[string]any{
					"type":        "boolean",
					"description": "Whether to include tool calls in the returned history",
				},
			},
			"required": []string{"sessionKey"},
		},
	},
	Type:  ToolTypeBuiltin,
	Group: GroupSessions,
}

SessionsHistoryTool tool definition.

View Source
var SessionsListTool = &Tool{
	Tool: mcp.Tool{
		Name:        "sessions_list",
		Description: "List sessions with optional filters and last messages.",
		Annotations: &mcp.ToolAnnotations{Title: "List Sessions"},
		InputSchema: map[string]any{
			"type": "object",
			"properties": map[string]any{
				"kinds": map[string]any{
					"type":  "array",
					"items": map[string]any{"type": "string"},
				},
				"limit": map[string]any{
					"type":        "number",
					"description": "Maximum number of sessions to return (default: 50)",
				},
				"activeMinutes": map[string]any{
					"type":        "number",
					"description": "Only include sessions active within this many minutes",
				},
				"messageLimit": map[string]any{
					"type":        "number",
					"description": "Include the last N messages for each session",
				},
			},
		},
	},
	Type:  ToolTypeBuiltin,
	Group: GroupSessions,
}

SessionsListTool tool definition.

View Source
var SessionsSendTool = &Tool{
	Tool: mcp.Tool{
		Name:        "sessions_send",
		Description: "Send a message into another session. Prefer the sessionKey from sessions_list; label is fallback only.",
		Annotations: &mcp.ToolAnnotations{Title: "Send to Session"},
		InputSchema: map[string]any{
			"type": "object",
			"properties": map[string]any{
				"sessionKey": map[string]any{
					"type":        "string",
					"description": "Session identifier from sessions_list (preferred canonical target)",
				},
				"label": map[string]any{
					"type":        "string",
					"description": "Session label fallback (can be ambiguous; sessionKey is preferred)",
				},
				"agentId": map[string]any{
					"type":        "string",
					"description": "Agent id filter for label lookups",
				},
				"message": map[string]any{
					"type":        "string",
					"description": "The message to send",
				},
				"timeoutSeconds": map[string]any{
					"type":        "number",
					"description": "Optional timeout for the remote session",
				},
			},
			"required": []string{"message"},
		},
	},
	Type:  ToolTypeBuiltin,
	Group: GroupSessions,
}

SessionsSendTool tool definition.

View Source
var SessionsSpawnTool = &Tool{
	Tool: mcp.Tool{
		Name:        "sessions_spawn",
		Description: "Spawn a background sub-agent run in an isolated session and announce the result back to the requester chat.",
		Annotations: &mcp.ToolAnnotations{Title: "Spawn Session"},
		InputSchema: map[string]any{
			"type": "object",
			"properties": map[string]any{
				"task": map[string]any{
					"type":        "string",
					"description": "Task description for the sub-agent.",
				},
				"label": map[string]any{
					"type":        "string",
					"description": "Optional label for the sub-agent run.",
				},
				"agentId": map[string]any{
					"type":        "string",
					"description": "Agent ID override for the sub-agent run.",
				},
				"model": map[string]any{
					"type":        "string",
					"description": "Optional model override (provider/model).",
				},
				"thinking": map[string]any{
					"type":        "string",
					"description": "Optional thinking level override.",
				},
				"runTimeoutSeconds": map[string]any{
					"type":        "number",
					"description": "Optional run timeout in seconds.",
				},
				"timeoutSeconds": map[string]any{
					"type":        "number",
					"description": "Legacy alias for runTimeoutSeconds.",
				},
				"cleanup": map[string]any{
					"type":        "string",
					"enum":        []string{"delete", "keep"},
					"description": "Cleanup policy for the spawned session.",
				},
			},
			"required": []string{"task"},
		},
	},
	Type:  ToolTypeBuiltin,
	Group: GroupSessions,
}

SessionsSpawnTool tool definition.

View Source
var WebSearch = &Tool{
	Tool: mcp.Tool{
		Name:        toolspec.WebSearchName,
		Description: toolspec.WebSearchDescription,
		Annotations: &mcp.ToolAnnotations{Title: "Web Search"},
		InputSchema: toolspec.WebSearchSchema(),
	},
	Type:    ToolTypeBuiltin,
	Group:   GroupSearch,
	Execute: executeWebSearch,
}

WebSearch is the web search tool definition.

Functions

func IsBossTool

func IsBossTool(toolName string) bool

IsBossTool checks if a tool name is a Boss agent tool.

func IsPluginTool

func IsPluginTool(tool *Tool) bool

IsPluginTool reports whether the tool is a plugin tool.

func IsSessionTool

func IsSessionTool(toolName string) bool

IsSessionTool checks if a tool name is a session tool.

func PluginIDForTool

func PluginIDForTool(tool *Tool) (string, bool)

PluginIDForTool returns the plugin id for a tool when available. This is used for OpenClaw-style plugin group expansion.

func ReadBool

func ReadBool(params map[string]any, key string, defaultVal bool) bool

ReadBool reads a boolean parameter from input.

func ReadInt

func ReadInt(params map[string]any, key string, required bool) (int, error)

ReadInt reads an integer parameter from input.

func ReadIntDefault

func ReadIntDefault(params map[string]any, key string, defaultVal int) int

ReadIntDefault reads an integer parameter with a default value.

func ReadMap

func ReadMap(params map[string]any, key string, required bool) (map[string]any, error)

ReadMap reads a map parameter from input.

func ReadNumber

func ReadNumber(params map[string]any, key string, required bool) (float64, error)

ReadNumber reads a numeric parameter from input. Following clawdbot's readNumberParam pattern.

func ReadString

func ReadString(params map[string]any, key string, required bool) (string, error)

ReadString reads a string parameter from input. Following clawdbot's readStringParam pattern.

func ReadStringArray

func ReadStringArray(params map[string]any, key string) []string

ReadStringArray reads a string array parameter, returning nil if not present. Convenience wrapper around ReadStringSlice that ignores errors.

func ReadStringDefault

func ReadStringDefault(params map[string]any, key, defaultVal string) string

ReadStringDefault reads a string parameter with a default value.

func ReadStringSlice

func ReadStringSlice(params map[string]any, key string, required bool) ([]string, error)

ReadStringSlice reads a string array parameter from input.

Types

type AgentData

type AgentData struct {
	ID           string                       `json:"id"`
	Name         string                       `json:"name"`
	Description  string                       `json:"description,omitempty"`
	Model        string                       `json:"model,omitempty"`
	SystemPrompt string                       `json:"system_prompt,omitempty"`
	Tools        *toolpolicy.ToolPolicyConfig `json:"tools,omitempty"`
	Subagents    *SubagentConfig              `json:"subagents,omitempty"`
	Temperature  float64                      `json:"temperature,omitempty"`
	IsPreset     bool                         `json:"is_preset,omitempty"`
	CreatedAt    int64                        `json:"created_at"`
	UpdatedAt    int64                        `json:"updated_at"`
}

AgentData represents agent data for boss tools (avoids import cycle).

type AgentStoreInterface

type AgentStoreInterface interface {
	LoadAgents(ctx context.Context) (map[string]AgentData, error)
	SaveAgent(ctx context.Context, agent AgentData) error
	DeleteAgent(ctx context.Context, agentID string) error
	ListModels(ctx context.Context) ([]ModelData, error)
	ListAvailableTools(ctx context.Context) ([]ToolInfo, error)
	RunInternalCommand(ctx context.Context, roomID string, command string) (string, error)
	// Room management
	CreateRoom(ctx context.Context, room RoomData) (string, error)
	ModifyRoom(ctx context.Context, roomID string, updates RoomData) error
	ListRooms(ctx context.Context) ([]RoomData, error)
}

AgentStoreInterface is the interface that the boss tools need. This matches the AgentStore interface in the agents package but avoids import cycle.

type BossToolExecutor

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

BossToolExecutor handles boss tool execution with access to the agent store.

func NewBossToolExecutor

func NewBossToolExecutor(store AgentStoreInterface) *BossToolExecutor

NewBossToolExecutor creates a new boss tool executor.

func (*BossToolExecutor) ExecuteCreateAgent

func (e *BossToolExecutor) ExecuteCreateAgent(ctx context.Context, input map[string]any) (*Result, error)

ExecuteCreateAgent handles the create_agent tool.

func (*BossToolExecutor) ExecuteDeleteAgent

func (e *BossToolExecutor) ExecuteDeleteAgent(ctx context.Context, input map[string]any) (*Result, error)

ExecuteDeleteAgent handles the delete_agent tool.

func (*BossToolExecutor) ExecuteEditAgent

func (e *BossToolExecutor) ExecuteEditAgent(ctx context.Context, input map[string]any) (*Result, error)

ExecuteEditAgent handles the edit_agent tool.

func (*BossToolExecutor) ExecuteForkAgent

func (e *BossToolExecutor) ExecuteForkAgent(ctx context.Context, input map[string]any) (*Result, error)

ExecuteForkAgent handles the fork_agent tool.

func (*BossToolExecutor) ExecuteListAgents

func (e *BossToolExecutor) ExecuteListAgents(ctx context.Context, _ map[string]any) (*Result, error)

ExecuteListAgents handles the list_agents tool.

func (*BossToolExecutor) ExecuteListModels

func (e *BossToolExecutor) ExecuteListModels(ctx context.Context, _ map[string]any) (*Result, error)

ExecuteListModels handles the list_models tool.

func (*BossToolExecutor) ExecuteModifyRoom

func (e *BossToolExecutor) ExecuteModifyRoom(ctx context.Context, input map[string]any) (*Result, error)

ExecuteModifyRoom handles the modify_room tool.

func (*BossToolExecutor) ExecuteRunInternalCommand

func (e *BossToolExecutor) ExecuteRunInternalCommand(ctx context.Context, input map[string]any) (*Result, error)

ExecuteRunInternalCommand handles the run_internal_command tool.

type ContentBlock

type ContentBlock struct {
	Type     string `json:"type"`               // "text", "image"
	Text     string `json:"text,omitempty"`     // For text blocks
	Data     string `json:"data,omitempty"`     // Base64 for images
	MimeType string `json:"mimeType,omitempty"` // For images
}

ContentBlock supports multi-modal results (text, images, artifacts).

type ModelData

type ModelData struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Provider    string `json:"provider,omitempty"`
	Description string `json:"description,omitempty"`
}

ModelData represents model data for boss tools.

type Registry

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

Registry manages available tools with grouping and aliasing support.

func DefaultRegistry

func DefaultRegistry() *Registry

DefaultRegistry returns a registry with all default tools registered.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new tool registry.

func (*Registry) All

func (r *Registry) All() []*Tool

All returns all registered tools.

func (*Registry) Register

func (r *Registry) Register(tool *Tool)

Register adds a tool to the registry.

type Result

type Result struct {
	Status  ResultStatus   `json:"status"`            // success, error, partial
	Content []ContentBlock `json:"content,omitempty"` // Multi-block: text, images
	Details map[string]any `json:"details,omitempty"` // Structured metadata for parsing
	Error   string         `json:"error,omitempty"`
}

Result standardizes tool output following clawdbot's jsonResult pattern.

func ErrorResult

func ErrorResult(toolName, message string) *Result

ErrorResult creates an error result. Follows clawdbot pattern: don't throw, return structured errors.

func JSONResult

func JSONResult(payload any) *Result

JSONResult creates a structured JSON result from any payload. Following clawdbot's jsonResult pattern.

func (*Result) HasImages

func (r *Result) HasImages() bool

HasImages returns true if the result contains image blocks.

func (*Result) IsError

func (r *Result) IsError() bool

IsError returns true if the result indicates an error.

func (*Result) IsSuccess

func (r *Result) IsSuccess() bool

IsSuccess returns true if the result indicates success.

func (*Result) Text

func (r *Result) Text() string

Text returns the text content from the result. Returns the first text block content, or the error message if status is error.

type ResultStatus

type ResultStatus string

ResultStatus indicates the outcome of tool execution.

const (
	// ResultSuccess indicates the tool completed successfully.
	ResultSuccess ResultStatus = "success"
	// ResultError indicates the tool failed with an error.
	ResultError ResultStatus = "error"
)

type RoomData

type RoomData struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	AgentID      string `json:"agent_id,omitempty"`
	SystemPrompt string `json:"system_prompt,omitempty"`
	CreatedAt    int64  `json:"created_at"`
}

RoomData represents room data for boss tools.

type SubagentConfig

type SubagentConfig struct {
	Model       string   `json:"model,omitempty"`
	AllowAgents []string `json:"allowAgents,omitempty"`
}

SubagentConfig mirrors OpenClaw-style subagent defaults for tools API payloads.

type Tool

type Tool struct {
	mcp.Tool                                                                  // Name, Description, InputSchema
	Type     ToolType                                                         // builtin, provider, plugin, mcp
	Group    string                                                           // group:search, group:code, etc.
	PluginID string                                                           // Optional plugin id for grouping
	Execute  func(ctx context.Context, input map[string]any) (*Result, error) // nil for provider tools
}

Tool wraps an MCP tool with execution logic and metadata.

func AllTools

func AllTools() []*Tool

AllTools returns all tools (builtin + provider markers).

func BossTools

func BossTools() []*Tool

BossTools returns all boss agent tools.

func BuiltinTools

func BuiltinTools() []*Tool

BuiltinTools returns all locally-executable builtin tools.

func GetTool

func GetTool(name string) *Tool

GetTool returns any tool by name (builtin or provider).

func NexusTools

func NexusTools() []*Tool

func SessionTools

func SessionTools() []*Tool

SessionTools returns the cross-session tools available to non-boss agents.

func (*Tool) Clone

func (t *Tool) Clone() *Tool

Clone creates a copy of the tool.

type ToolInfo

type ToolInfo struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Type        ToolType `json:"type"`
	Group       string   `json:"group,omitempty"`
	Enabled     bool     `json:"enabled"`
}

ToolInfo provides metadata about a tool for listing.

type ToolType

type ToolType string

ToolType categorizes tools by their execution model.

const (
	// ToolTypeBuiltin are tools implemented locally.
	ToolTypeBuiltin ToolType = "builtin"
	// ToolTypeProvider are tools handled by the AI provider's API.
	ToolTypeProvider ToolType = "provider"
	// ToolTypePlugin are external plugins (like OpenRouter's :online).
	ToolTypePlugin ToolType = "plugin"
	// ToolTypeMCP are tools from MCP servers.
	ToolTypeMCP ToolType = "mcp"
)

Jump to

Keyboard shortcuts

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