MANUAL / SKILLS AND TOOLS 14 / 29
A file in $OSCAR_HOME/tools/ becomes a tool:
return {
name = "word_count",
description = "Count the words in a workspace file.",
parameters = { type = "object",
properties = { path = { type = "string" } },
required = { "path" } },
capabilities = { "fs.read" }, -- or "fs.write" (the tool then asks first)
run = function(args)
local n = 0
for _ in oscar.fs.read(args.path):gmatch("%S+") do n = n + 1 end
return { words = n } -- strings as-is, tables as JSON
end,
}- Host API:
oscar.fs.read(path),oscar.fs.list(path),oscar.fs.write(path, text)— workspace only, never inside.git;oscar.json.encode/decode;printgoes into the tool's output. - Each call runs in a fresh Lua 5.4 VM without
io,os,package,require,loadordofile, limited to 50M instructions and 32 MiB. - Names of built-in tools are reserved;
oscar doctorlists loaded tools and why a file was refused.execandhttpcapabilities are not available. - You cannot create Lua tools yourself:
$OSCAR_HOMEis outside the workspace. Write the file in the workspace and ask the user to move it. - Plugins can ship Lua tools as well, named
plugin_<name>_…or with the plugin's namespace and limited to the file reach the plugin declares; they read the plugin's settings asoscar.config(see Plugins).