Documentation
¶
Overview ¶
Package builtin provides the built-in tools for the OK agent.
bash_security.go — command classification and whitelist for bash.Execute
System prompt component sizes (measured): - DefaultSystemPrompt: ~1900 bytes (~475 tokens) - LanguagePolicy: ~290 bytes (~72 tokens) - Memory/skills/env: ~1500 bytes (~375 tokens) - Tool schemas (36): ~14723 bytes (~3680 tokens) -------------------------------------------------- TOTAL per-turn prefix: ~18413 bytes (~4602 tokens)
Optimization targets: 1. Minify schemas (-30% = -4400 bytes / -1100 tokens) ← BIGGEST WIN 2. Shorten descriptions (-50% = -2400 bytes / -600 tokens) 3. Remove redundant tools from prompt during simple tasks
Every turn saved = ~1800 fewer tokens in prefix. 20-turn session = 36,000 fewer tokens = ~$3.60 savings (DeepSeek Flash).
Package builtin — gosyntax.go replaced by precheck.go. precheckGoFile in precheck.go handles all Go file validation (syntax + go vet).
Package builtin — dead code removed; model-router tool was never wired.
Package builtin provides OK's compile-time built-in tools. Each tool self-registers via init(); main blank-imports this package to wire them in.
Index ¶
- func CheckCommand(cmd string) error
- func ConfineBash(spec sandbox.Spec) tool.Tool
- func ConfineReaders(roots []string) []tool.Tool
- func ConfineWriters(roots []string) []tool.Tool
- func NewComputerUseTool(baseURL, apiKey, model string) tool.Tool
- func NewOCRTool(baseURL, apiKey, model string) tool.Tool
- func NewToolGroupsTool(reg tool.RegistrySetGroups) tool.Tool
- func NewTranslateTool(baseURL, apiKey, model string) tool.Tool
- func SetSemanticEngine(eng *semantic.Engine)
- func ToolGroup(name string) string
- type EditStep
- type Workspace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckCommand ¶
CheckCommand runs before bash execution. Returns nil to allow, error to deny.
func ConfineBash ¶
ConfineBash returns the bash built-in bound to an OS-sandbox spec, overriding the unconfined instance registered at init. When the spec enforces, bash runs each command through the sandbox (see package sandbox).
func ConfineReaders ¶
ConfineReaders returns the file-reading built-ins (read_file, ls, glob, grep) bound to roots — the only directories they may access. Follows the same pattern as ConfineWriters: an empty roots slice yields unconfined readers.
func ConfineWriters ¶
ConfineWriters returns the file-writing built-ins (write_file, edit_file, multi_edit) bound to roots — the only directories they may modify. The composition root adds these to the per-run registry to override the unconfined instances registered at init time, so writes stay inside the workspace by default. roots may be relative; they are resolved to absolute, symlink-free paths once here. An empty roots slice yields unconfined writers.
func NewComputerUseTool ¶
NewComputerUseTool creates a Tool that runs the screenshot→analyze→act→verify loop.
func NewOCRTool ¶
NewOCRTool creates a Tool that extracts text from images via LLM vision API.
func NewToolGroupsTool ¶
func NewToolGroupsTool(reg tool.RegistrySetGroups) tool.Tool
NewToolGroupsTool creates a tool-groups tool bound to a registry.
func NewTranslateTool ¶
NewTranslateTool creates a Tool that translates text using the configured LLM.
func SetSemanticEngine ¶
SetSemanticEngine installs a semantic engine for the semantic-search tool. Called during boot. If nil, the tool reports "not configured".
Types ¶
type EditStep ¶
type EditStep struct {
OldString string `json:"old_string"`
NewString string `json:"new_string"`
ReplaceAll bool `json:"replace_all,omitempty"`
}
editStep is one edit in a multi_edit operation. Exported so preview.go can reuse the same apply logic.
type Workspace ¶
Workspace binds all file tools to a project directory. When Dir is non-empty, relative paths are resolved within it and writes outside it are confined. AllowWrite lists additional directories file-writer tools may modify (e.g. /tmp for temporary output).
Source Files
¶
- autoheal.go
- bash.go
- bash_security.go
- bgjobs.go
- browser.go
- capabilities.go
- completestep.go
- computeruse.go
- confine.go
- cost_opt.go
- covenant.go
- database.go
- debug.go
- deploy.go
- desktop.go
- digest.go
- editcore.go
- editfile.go
- git.go
- glob.go
- goprofile.go
- gosyntax.go
- grep.go
- groups.go
- imageread.go
- ls.go
- maketool.go
- modelrouter.go
- multiedit.go
- ocr.go
- okverify.go
- okverify_v2.go
- planner.go
- precheck.go
- preview.go
- rag.go
- readfile.go
- repo.go
- schedule.go
- selfscan.go
- semanticsearch.go
- stylecheck.go
- symbolfind.go
- todo.go
- toolgroups.go
- translate.go
- undo.go
- videoanalyze.go
- vulncheck.go
- wakeword.go
- webfetch.go
- workflow.go
- workspace.go
- writefile.go