Cortex
Search help⌘K

Applet script calls and builder tools

Updated 19 November 2026Cortex 0.26.07 min read
On this page

Everything an applet's script may call on the cortex object, and the five tools its builder uses.

An applet's script is JavaScript in a sandbox. It has no file, network or process access of its own. Everything it does is a call on one global object, cortex, and each call returns a promise. This page lists the calls, and the five tools the applet builder uses. For the whole list of Cortex tools, see Cortex tools reference.

How a call is checked. Cortex checks every call against what the applet's manifest declares under needs and against what you allowed in its configuration. A call that is refused rejects with its reason. See Decide what an applet may reach.

Limits of a run. A handler stops after 5 seconds. A run has 256 MB of memory and at most 20 timers, none firing more than once a second. At most 100 calls wait at once, 4 of them network requests and 1 a prompt. At most 5 applets run at once. You can lower each limit in the configuration.

No browser tools. There is no fetch, XMLHttpRequest, require, import or DOM. console.log, console.warn and console.error write to the run's log. setTimeout, setInterval and clearTimeout work. The script starts with cortex.on("start", async () => { … }).

Try it

You don't call these tools yourself: you ask in your own words, in a session, and the agent picks the tools. Saying with Cortex or naming what you want to see (a view, a tab, the Stack) makes it reach for them.

You type What the agent uses
Make me an applet that shows this month's expenses by category as a bar chart the builder tools, then cortex.ui.show in the script
Make an applet that asks @ledger to check a pasted invoice cortex.minis.ask in the script
Add a button to the applet that fetches today's exchange rates applet_write, then cortex.net.fetch (its domain must be declared)

Screens

The screens are the same view format sessions use, with one addition: a masked password field, which only an applet's screen may hold. These calls need nothing declared.

cortex.ui.show(docOrScreenName, { id })

Shows a screen: a CXUI document, or the name of a file in the applet's screens/ folder. With id, it replaces the screen with that id. Returns { id }.

cortex.ui.update(id, ops)

Patches a screen by node id, with the operations of ui_update. Returns { kept }.

cortex.ui.read(id)

Returns { id, title, values, open }.

cortex.ui.close(id)

Closes a screen.

cortex.ui.on(event, handler)

Registers a handler for submitted, action, change, closed or *. The handler gets { view, event, action, name, row, field, value, values }. A script waits by handlers, never by blocking.

Files

Files need needs.files of read or readwrite, and a context and folder set in the configuration. Paths are relative to that folder, and nothing outside it is reached, a link out of it included. A file is at most 50 MB.

Call Does Returns
cortex.files.list(path = ".") Lists a folder. [{ name, folder, size, modified }]
cortex.files.read(path, { encoding: "base64" }) Reads a file as text, or as base64. The text or the base64
cortex.files.write(path, textOrJSON, { encoding: "base64" }) Writes a file and creates folders. Needs readwrite and Read and write in the configuration. Nothing
cortex.files.move(from, to) Moves or renames. Nothing
cortex.files.delete(path) Moves a file to the Trash. Nothing

Network

cortex.net.fetch(url, { method, headers, body, encoding })

Makes an https request to a domain the manifest declares under needs.network and you ticked. The host makes the request and follows a redirect only to a ticked domain. It gives up after 30 seconds. Returns { status, headers, body, base64 }, at most 20 MB.

Agent and minis

cortex.agent.prompt(text, { files, schema })

Sends one prompt to the agent and model set in the configuration, with files of the folder attached. It needs needs.agent. It returns the reply's text, or JSON checked against schema. The agent answers and never acts, so it has no tools. A run may send at most 20 prompts by default (100 at most), and they are billed to the account as a session's are. One runs at a time.

cortex.minis.ask(alias, text)

Asks a mini your configuration names one question and returns its text. It needs needs.minis. A mini bound to a context answers as a session of it, and what it would ask comes to you in the applet's panel.

Cortex tools

cortex.tools.call(name, args)

Calls one Cortex tool by name and returns its result. The tool must be listed in the manifest's needs.tools and ticked in the configuration, or the call fails with a reason that says which. The call is bound to the configuration's context. A tool that works in a context fails if the configuration sets none. A tool that asks a session asks you the same way, with the applet named as who asks.

Which tools. The calls look up the tools Cortex serves under Settings → MCP, so a part that is switched off is not there. The specification names the Cortex control tools. The code finds any tool of the server, the vector store's included. The views have cortex.ui, so an applet has no need to call the ui_ tools. Tools that exist only for minis and task runs are not there. See Cortex tools reference for each family and its tier.

Commands

cortex.commands.run(name, values)

Runs a command the manifest declares under needs.commands and you switched on, with its {key} placeholders filled from values. Each value is a string or number of at most 1 000 characters, with no line break, and never starting with -. Nothing runs through a shell. The command runs inside the OS sandbox. It ends at the configuration's time limit (60 seconds by default, 300 at most). One runs at a time per run. Returns { exitCode, stdout, stderr, timedOut, truncated }, each output cut at 4 MB.

const r = await cortex.commands.run("orders", { year: "2026" });
if (r.exitCode === 0) { const orders = JSON.parse(r.stdout); }

Saved data and secrets

These need nothing declared.

Call Does
cortex.store.get(key), cortex.store.set(key, json), cortex.store.delete(key) The applet's own key and value store. JSON, at most 5 MB, kept across runs and versions, never shared.
cortex.secrets.get(key), cortex.secrets.set(key, string), cortex.secrets.delete(key) Secrets in the Keychain under the applet's id. At most 20, 4 KB each. Never in the store, the log or a share.
cortex.assets.read(name, { encoding: "base64" }) Reads a file of the applet's assets/ folder.

You

These work for every applet. No manifest asks for them, and the configuration has no switch for them.

Call Does
cortex.notify(title, body) Posts a macOS notification.
cortex.clipboard.write(text) Writes text to the clipboard. It cannot read it.

The builder's tools

When you make or change an applet, an agent writes it. That builder is served five tools of the Cortex MCP server and none of the others. They reach only the applet's draft. See Make an applet.

applet_reference

Returns part of the reference for writing an applet. The agent starts with overview.

Parameter Type Required Meaning
topic string no overview (default), manifest, screens, script, examples, commands, a node type, or a call family: ui, files, net, agent, minis, tools, store, secrets, assets, notify, clipboard.

applet_read

A file of the draft, as text.

Parameter Type Required Meaning
path string yes applet.json, main.js, screens/<name>.json or assets/<name>.

applet_write

Writes a file of the draft. The manifest's id is the applet's whatever it says, and its version is set when you save.

Parameter Type Required Meaning
path string yes As for applet_read.
content string yes The file's text, within the package's limits.

applet_check

Lists every problem of the draft as path: message: the manifest, every screen against the schema, the script parsed, and the limits. It is empty when the draft is ready to try. No parameters. Read-only.

applet_try

Runs the draft beside the chat, under what you allowed with Configure… in the builder. It plays the events and gives back the screens it showed, its log, the calls refused and the errors.

Parameter Type Required Meaning
events array of objects no Clicks and values to play on the front screen. Each: event (submitted, action or change), action (a button id), name, field, value and values (an object of input id to value).

Something wrong or missing? Tell us

Open this page in your browser