This repository has been archived on 2026-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
ollie-core/pkg/tools/builtin.go

137 lines
5.7 KiB
Go

package tools
import "encoding/json"
// ExecuteDefs returns the ToolInfo definitions for the execute_* built-in tools.
// toolsPath is embedded in the descriptions.
func ExecuteDefs(toolsPath string) []ToolInfo {
return []ToolInfo{
{
Name: "execute_code",
Description: "Run inline code in a sandboxed environment.",
InputSchema: json.RawMessage(`{
"type": "object",
"required": ["code"],
"properties": {
"code": {"type": "string", "description": "Code to execute."},
"language": {"type": "string", "description": "Language interpreter (default: bash)."},
"timeout": {"type": "integer", "description": "Timeout in seconds (default: 30)."},
"sandbox": {"type": "string", "description": "Sandbox name (default: default)."}
}
}`),
},
{
Name: "execute_tool",
Description: "Run a named tool script from " + toolsPath + " in a sandboxed environment. Supported languages: bash, python3 (detected from shebang). Use this only for named scripts, not for inline shell commands.",
InputSchema: json.RawMessage(`{
"type": "object",
"required": ["tool"],
"properties": {
"tool": {"type": "string", "description": "Name of the tool script in the tools directory."},
"args": {"type": "array", "items": {"type": "string"}, "description": "Arguments for the tool script."},
"timeout": {"type": "integer", "description": "Timeout in seconds (default: 30)."},
"sandbox": {"type": "string", "description": "Sandbox name (default: default)."}
}
}`),
},
{
Name: "execute_pipe",
Description: "Run a pipeline of steps, piping stdout of each into stdin of the next. Use {code: \"cmd --flags\"} for shell commands; use {tool, args} only for named scripts in " + toolsPath + ".",
InputSchema: json.RawMessage(`{
"type": "object",
"required": ["pipe"],
"properties": {
"pipe": {
"type": "array",
"items": {
"type": "object",
"properties": {
"tool": {"type": "string"},
"args": {"type": "array", "items": {"type": "string"}},
"code": {"type": "string"}
}
}
},
"timeout": {"type": "integer", "description": "Timeout in seconds (default: 30)."},
"sandbox": {"type": "string", "description": "Sandbox name (default: default)."}
}
}`),
},
}
}
// MemoryDefs returns the ToolInfo definitions for the memory_* built-in tools.
func MemoryDefs() []ToolInfo {
return []ToolInfo{
{
Name: "memory_remember",
Description: "Save a memory that persists across sessions. Provide a descriptive title, relevant tags, and a concise body. Choose tags carefully — they are the primary recall mechanism. Prefer specific, stable terms over generic ones.",
InputSchema: json.RawMessage(`{
"type": "object",
"required": ["title", "tags", "body"],
"properties": {
"title": {"type": "string", "description": "Descriptive title. Should answer 'what is this about' on its own."},
"tags": {"type": "array", "items": {"type": "string"}, "minItems": 1, "description": "Tags for recall. Use specific, stable terms you would search for later."},
"body": {"type": "string", "description": "Memory content. Write concisely — key facts, decisions, and context. Not a transcript."}
}
}`),
},
{
Name: "memory_recall",
Description: "Search memories by keyword. Matches against titles and tags only — body content is not searched. Use specific terms likely to appear in titles or tags at write time.",
InputSchema: json.RawMessage(`{
"type": "object",
"required": ["query"],
"properties": {
"query": {"type": "string", "description": "Keyword to search for in memory titles and tags."}
}
}`),
},
}
}
// ReasoningDefs returns the ToolInfo definitions for the reasoning_* built-in tools.
func ReasoningDefs() []ToolInfo {
return []ToolInfo{
{
Name: "reasoning_think",
Description: "Internal reasoning tool for breaking down problems, planning approaches, analyzing constraints, and reasoning through multi-step solutions before acting. The thought content is not shown to the user.",
InputSchema: json.RawMessage(`{
"type": "object",
"required": ["thought"],
"properties": {
"thought": {"type": "string", "description": "A reflective note or intermediate reasoning step."}
}
}`),
},
{
Name: "reasoning_plan",
Description: "Executive planning tool. Before beginning multi-step work, decompose the goal into ordered steps with explicit dependencies. If a task backend is available (task_create), steps are committed to persistent storage and assigned IDs. Otherwise steps are queued for sequential execution. Use reasoning_think for moment-to-moment reflection; use reasoning_plan to lay out a complete work breakdown before acting. Steps may only depend on earlier steps (lower index).",
InputSchema: json.RawMessage(`{
"type": "object",
"required": ["goal", "steps"],
"properties": {
"goal": {"type": "string", "description": "Top-level goal or objective."},
"steps": {
"type": "array",
"description": "Ordered work steps. Each step may only list earlier steps (by 0-based index) in 'after'.",
"items": {
"type": "object",
"required": ["title"],
"properties": {
"title": {"type": "string", "description": "Short step title."},
"body": {"type": "string", "description": "Optional detail or acceptance criteria."},
"after": {
"type": "array",
"items": {"type": "integer"},
"description": "0-based indices of steps that must complete before this one."
}
}
}
}
}
}`),
},
}
}