Expand description
Helpers for writing plugins from inside byob (the model’s make_tool, edit_plugin, …):
derive_schema: the JSON Schema of a Pythondef run(arg: type = default, …), read from its type hints by a small Python shim that only parses the code (ast), never runs it;tool_script: the code plus a runner footer that callsrun()with the JSON arguments from stdin and prints what it returns;upsert_tool/new_manifest: add or replace a tool in a plugin’sbyob-plugin.json, checked with the same parser (and error messages) the loader uses;fingerprint: a cheap “did anything change” hash of a plugin folder (sizes and times).
Structs§
- Derived
- What
derive_schemafound. - Fnv
- FNV-1a, 64 bit: stable across runs (unlike std’s
DefaultHasher). - Tool
Decl - A tool to put in a manifest.
- Wanted
Setting - A setting a tool asks for (
make_tool’ssettings): an environment variable name, and whether its value is secret (an API key) — then it lives in secrets.json.
Constants§
- MAX_
CODE_ BYTES - Longest tool code accepted.
- RUNNER_
MARK - Marks where the runner footer starts in a tool script; everything from it on is byob’s.
Functions§
- derive_
schema - The JSON Schema of
def run(…)incode, from its type hints, defaults and docstring (Args:lines become descriptions). The code is parsed, never executed. Runspythoninsandbox(no network) when given. - fingerprint
- A hash of the names, sizes and modification times of the files in
dir(three levels down; dot folders and__pycache__skipped). Changes when a manifest, SKILL.md, agent file or script is edited, added or removed. Missing → a fixed value. - fingerprint_
into - Add
dir’s files toh(seefingerprint). - last_
lines - The last
nlines oftext(a traceback’s useful end). - new_
manifest - A fresh manifest for plugin
id. - read_
manifest_ json - The manifest JSON in
dir(a fresh one foridif there is none yet). - remove_
tool - Remove tool
namefrom the manifest indir(its script stays). Whether it was there. - script_
code - The code part of a tool script (without byob’s runner footer).
- tool_
script code(with any earlier runner footer removed) followed by the runner footer.- upsert_
tool - Add
toolto the manifest of pluginidindir(replacing a tool with the same name), with its settings and network permission, and write it. Returns whether it replaced one. - write_
manifest - Check
manifestwith the loader’s own rules and write it todir(pretty-printed). Nothing is written if it doesn’t pass; the error is the loader’s message.