Script API#
Everything an Ohm script can call. Every object accepts both obj.fn(x) and obj:fn(x).
Host calls are asynchronous underneath but read as straight-line code — the runtime
schedules coroutines and resumes them when results arrive.
browser#
| Function |
Returns |
browser.open(url, opts) |
a tab, after the page has loaded |
browser.tabs() |
a list of tabs |
browser.active() |
the active tab, or nil |
browser.get(id) |
a tab by id |
opts takes hidden (default false) and activate (default not hidden). A tab opened
by a script is marked as an agent tab.
local tab = browser.open("https://example.com", { hidden = true })
tab#
| Function |
Returns |
tab.go(url) |
the tab, after loading |
tab.info() |
{ id, url, title, hidden, loading } |
tab.url(), tab.title() |
strings |
tab.text() |
document.body.innerText |
tab.html() |
documentElement.outerHTML |
tab.eval(js) |
the value of the expression |
tab.query(sel) |
{ tag, text, href, value, id } or nil |
tab.queryAll(sel) |
a list of the same (max 1000) |
tab.click(sel) |
scrolls into view, clicks, settles |
tab.type(sel, text) |
focuses, selects, types |
tab.press(key) |
a named key (Enter, Tab, Escape, arrows…) or a character |
tab.waitFor(sel, ms) |
polls every 200 ms, throws on timeout (default 10 s) |
tab.scroll(dy) |
the new scroll position |
tab.screenshot() |
a path under .ohm/shots/ |
tab.pdf(path) |
prints the page to PDF, returns the path |
tab.show(), tab.hide(), tab.activate() |
the tab |
tab.close() |
|
Element text is truncated at 4000 characters.
| Function |
Returns |
ai.generate(prompt, opts) |
the reply as a string |
ai.json(prompt, opts) |
the reply parsed as JSON |
ai.profiles() |
the profiles, each with hasApiKey but never a key |
ai.saveProfile(profile) |
creates or updates a profile (never credentials) |
ai.useProfile(name) |
switches the active profile |
opts: profile, model, system, temperature, maxTokens.
local answer = ai.generate("Summarise:\n" .. tab.text(), { profile = "Claude" })
local data = ai.json("List three colours as an array of strings.")
Confined to the scripts folder; .ohm is refused.
| Function |
Returns |
fs.read(path) |
contents |
fs.write(path, text) |
|
fs.list(dir) |
names |
fs.exists(path) |
boolean |
fs.url(path) |
a file:// url for that path, ready for browser.open |
fs.url resolves inside the scripts folder like every other fs call, so a script
cannot turn it into a url for the rest of the disk.
view#
Turning a result into something worth looking at. Rendering is substitution only — a
template formats data and can never run anything. See
view templates and results.
| Function |
Returns |
view.list() |
the templates in the library |
view.render(name, data) |
the filled template, as text |
view.show(text, title, format) |
an id; puts text in the Results panel |
view.present(name, data, title) |
renders a template and shows it — the usual one |
view.results() |
everything shown so far this session |
format is "markdown" (default), "html" or "text".
project#
All of these need an active project (or one set with project.use); a script inside
projects/<id>/ is bound to that project automatically.
| Function |
Returns |
project.use(id) |
project info |
project.list() |
every project |
project.info() |
{ id, name, kind, question, … } |
project.links() |
the links |
project.addLink(link) |
a link table or a bare URL; dedupes by URL |
project.docs(), project.data() |
file names |
project.readDoc(name), project.writeDoc(name, text) |
|
project.readData(name) |
parsed rows (.jsonl, .json, .csv) |
prompts#
| Function |
Returns |
prompts.list() |
names |
prompts.render(name, vars, version) |
{ system, user, missing, model, version } |
prompts.run(name, vars, opts) |
the reply text |
curves#
| Function |
Returns |
curves.list() |
names |
curves.get(name) |
the curve document |
curves.eval(name, x) |
the typed value at x (0…1) |
curves.sample(name, n) |
n typed values (1…10000) |
experiments#
| Function |
Returns |
experiments.list() |
names |
experiments.run(name) |
the finished run, with per-trial summaries |
specs#
| Function |
Returns |
specs.list() |
names |
specs.get(name) |
the spec document |
specs.save(name, doc) |
|
specs.markdown(name, write) |
markdown, or the written path when write is true |
models#
| Function |
Returns |
models.dir() |
the models folder |
models.list() |
local models |
models.search(query, filter) |
Hub results |
models.files(repo) |
files in a repo, with sizes |
models.download(repo, files) |
waits for the download to finish |
There is deliberately no script API for deleting models, changing the models folder or
setting the Hugging Face token.
lib#
| Function |
Returns |
lib.list() |
every entry with its kind and description |
lib.get(name) |
one entry, body included |
lib.use(name) |
a function entry, loaded and cached |
lib.run(name, args, opts) |
runs a prompt entry through the model, or calls a function entry |
lib.render(name, args) |
the rendered prompt, without sending it |
remote#
Every one of these fails while the master switch is off (Settings → Remote).
| Function |
Returns |
remote.names() |
the configured nicknames |
remote.enabled() |
whether sending is allowed at all |
remote.read(name, path) |
the body as text |
remote.write(name, path, text) |
{ status, url } |
remote.list(name, dir) |
{ name, path, size?, modified?, directory? } |
ohm#
| Function |
Purpose |
ohm.matrix(v) |
read anything as a list (a scalar becomes one item) |
ohm.tabs(urls, opts) |
open a tab per url — what \Tab \times urls calls |
ohm.mul(a, b), ohm.send(a, b) |
what \times and <- compile to |
ohm.chat(tab, prompt, opts) |
type into a page and wait for the reply |
ohm.spawn(fn, …) |
start a concurrent task |
ohm.join(task) |
wait for one |
ohm.all(f1, f2, …) |
run several and collect the results |
ohm.sleep(ms) |
also plain sleep(ms), clamped to 10 minutes |
ohm.defop(family, name, fn) |
define an operator usable from math |
ohm.text(v), ohm.show(v), ohm.inspect(v) |
formatting |
ohm.display(v) |
emit on the result stream |
Values#
| Name |
Contents |
mem / \mathcal{M} |
persistent memory for this script |
ctx / \Gamma |
{ script, project, args, tab } |
params / \Theta |
{ profile, provider, model } for this run |
json |
encode, decode |
print, log.info/warn/error |
output |
Operators#
Callable as \Name_{\Family}(input; config):
| Family |
Operators |
\Psi reasoning |
Ask CoT ToT GoT SelfAsk Plan Reflect Critique Summarize |
\Psi coding |
OpenCode AxialCode SelectiveCode Codebook |
\Psi library |
Use |
\Gamma context |
Retrieve Search Fetch Rank Filter Compress MergeContext Ground Cite |
\Gamma tabs |
Tabs Close Read |
\mathcal{M} memory |
MemRead MemWrite MemAppend MemSearch MemSummarize MemForget |
\Sigma aggregate |
Join Vote Debate |
\Sigma structure |
Map Shuffle Rotate Reverse Transpose Zip Chunk Pick Flatten Unique Sort |
\Lambda agent |
ReAct Verify Fork Chat Publish |
Config may be positional or named. See The Ohm language.