PITWALL

Platform services

Preview

Preview. What Pitwall gives every tile, so authors don't build it themselves. Without a permission, each reaching only the tile's own things: timers (tasks), a key-value store (storage), settings and secrets (settings), the Log (log), requests about the tile's own views (ui), a SQLite database (sql), a toolbar button (toolbar) and the extension's own server (service). With a permission: the network, to the hosts the manifest names (net), notifications (notify), opening a file or a web page (show), the files of the project a view is open in (files), and the agents' questions group: your agents and their Next up (agents), badges on sidebar rows (badges) and questions in the floating control (asks) (below).

Pitwall adds a service only when a tile can't reasonably do without one. Each is checked by Pitwall, not by the SDK: a call without its permission fails with Denied and a line in the Log.

Errors

The calls that can fail return Result<_, HostError>:

ErrorMeans
DeniedThe tile isn't granted the permission this needs
BusyToo many calls or things at once (over 200 calls a second, or 32 timers); try again later
TooLargeOver a size limit or a quota
Invalid(why)An argument isn't valid; the text says which and why
Failed(why)Pitwall couldn't do it, such as a disk error
Decode(why)Stored data couldn't be read as the type asked for

Each has a plain message (Display), fit for the Log.

Tasks: timers

Timers are on the tile's context, since they call back into the tile:

CallDoes
cx.after(delay, f)Calls f once, after delay (a Duration)
cx.every(period, f)Calls f every period until cancelled
cx.cancel(timer)Stops a timer; one already finished is ignored

f gets the tile and the context, like a listener. Both return Option<Timer>: None (and a Log line) when it can't be made. A delay or period is at least 100 ms, and a tile has at most 32 timers at once. Call cx.notify() in the closure when what the tile shows changed.

Timers pause while the tile is hidden and go on when it is shown again. A repeating timer that was due while hidden fires once, not once per missed period. There is no background work while hidden: a tile polls only while you can see it.

Clocks

std::time::Instant and SystemTime work (WASI's clocks), so a tile can time a debounce or stamp what it stores; std::thread::sleep blocks the whole tile, so wait with a timer instead.

In tests time is virtual: it stands still until the test moves it, with advance(duration) (wait is the same), which fires each timer due on the way at its own time, and moves Instant and SystemTime with it. wait_for_text(text, timeout) moves it in small steps until the tile shows something. Harness::wall_clock() runs a test on the computer's clock instead.

Storage

The tile's own key-value store, in storage. Use it for what the user must not lose: it is written to disk after each call into the tile that changed it, and kept across restarts and updates, outside the extension's folder.

CallDoes
storage::get(key)The bytes of key, or None
storage::get_many(&keys)The bytes of each key, in order (None for a missing one), at most 1024 keys: one call, for reading many at once
storage::entries(prefix), storage::entries_json(prefix)Every key that starts with prefix with its value (bytes, or JSON with serde), in byte order: a list and get_many calls, so a tile reads all its records in a few calls
storage::set(key, value)Sets key to bytes
storage::delete(key)Removes key (a missing key is no error)
storage::list(prefix)The keys that start with prefix (all for ""), in byte order
storage::usage()The bytes the store takes now
storage::get_json(key), storage::set_json(key, &value)The same, as JSON with serde
storage::get_string(key)The value as text

The store holds at most 10 MiB in all; a write past that fails with TooLarge. Keys are 1 to 256 bytes of UTF-8 without control characters.

The blank template reads its count when it starts:

fn new(_cx: &mut Cx<Self>) -> Self {
    // What the user must not lose goes in storage: on disk at once,
    // kept across restarts and updates.
    let clicks = storage::get_json("clicks").ok().flatten().unwrap_or(0);
    App { clicks }
}

The list template keeps its whole list as JSON and notes a failed write in the Log:

fn save(&self) {
    if let Err(e) = storage::set_json("list", self) {
        log::warn(format!("the list wasn't saved: {e}"));
    }
}

For state that only has to survive a reload (what is being typed, a scroll position), use save_state instead (Quick start).

In tests, stored(key) and stored_json(key) read what the tile stored, and Harness::stored(key, value) (or stored_json) starts the tile with values already stored. restart() starts it again with the same storage and no saved state; reload() keeps the saved state too.

Settings

An extension declares its settings schema in the manifest's settings list. Its Setup view draws ordinary controls and places Pitwall's host-owned fields for values that grant access. Pitwall keeps the values and reports changes. Extensions without a Setup view retain the legacy generated form during this preview.

Each setting needs a key and type, with an optional default. Legacy label, placeholder, hint and required keys are still accepted for the generated form; host-owned fields use the schema key. The types:

TypeRead withDrawn as
textsettings::text(key)A text field
urlsettings::text(key)A text field for a URL
numbersettings::number(key)A number field (with min and max)
boolsettings::flag(key)A switch
choicesettings::text(key), which gives the option's valueA list of options, each with a value and a label
secretsettings::secret(key)A password field, kept in the system's secure store

settings::get(key) returns the value as a Value (Text, Number or Flag): what the user set, else the manifest's default, else None. A secret is never returned by get.

Use settings::secret_set(key) to learn whether a secret is set, and a secure field in the Setup view to let the user enter or remove it. The component receives only Event::SecretChanged { key, set }, without the value.

For HTTP, reference the secret instead of reading it:

let request = net::Request::get("https://api.example.com/items")
    .bearer("apiKey");
// Or: .secret_header("X-API-Key", "apiKey")

At the WIT boundary, an entire header value bearer(apiKey) means Bearer <value>; secret(apiKey) means the raw value. These two forms are reserved for references. Pitwall checks that the key is a declared secret and resolves it only for an explicitly granted net host, immediately before each send, including redirects. A missing secret or invalid header value is refused. A denied destination sends nothing; the legacy own-server bypass does not authorize secret headers.

Known secret values are redacted from Log lines and request error text. A server that echoes a secret in its response can still give that value to the component; use hosts you trust with the credential. Ordinary tile visuals can imitate a secure field, so enter credentials only through Pitwall's field behavior on the extension's page.

The legacy settings::secret(key) remains until the adapter migration removes it (plan 8c4), but returns Denied for a key entered through a secure field. Before writing the keychain, Pitwall durably marks that key as reference-only in host-owned extension data. A failed marker write refuses the secret save. The marker survives restarts, updates, Go back, and removing or replacing just the value. Existing legacy keys never entered through a secure field keep their old API behavior, so old tiles continue working; new extensions should use references.

settings::open() opens the extension's page in the Extensions tile, at its Setup view when it has one (below), for a "Set up" button when something the tile needs isn't set.

The Setup view

An extension can draw its own setup screen: its Setup view. Name it in the manifest:

"contributes": { "setup": { "view": "setup" } }

The extension's page in the Extensions tile then shows, top to bottom: its header (name, version, switch, status), its Setup view, and Pitwall's own parts (permissions, agent tools, Activity, Log). Pitwall draws those parts itself, so a Setup view can't hide or restyle them. An extension without a Setup view shows its header and Pitwall's parts.

The Setup view is an ordinary view of the extension's component (the one its tiles name, so it needs at least one tile). Its view id is the id the manifest gives, and ViewInfo::tile is that id too: draw it in render like any view (SETUP_VIEW is "setup", the usual id). It can use everything a tile can: events, timers, net, storage. It is as tall as its content, up to 560 px, then it scrolls inside, and it follows the theme and focus as a tile does. While its first frame is on its way, or while the extension is off, the page shows a placeholder in its place; if the component stops, the page says "Setup stopped" with Restart. It is open while the page shows, and let go when the page closes.

fn render(&mut self, view: &str, cx: &mut Cx<Self>) -> impl IntoElement {
    if view == SETUP_VIEW {
        return v_flex().gap(px(12.0)).p(px(14.0))
            .child(text("Hello greets you in its tiles."))
            .child(key_values().entry("Greeting", self.greeting.clone()))
            .into_any();
    }
    self.main(cx).into_any()
}

While an extension has a Setup view, Pitwall doesn't draw a form for its settings on its page. In tests, Harness::setup() starts it with its Setup view open, and Session::open_setup() opens it beside a tile's view.

Saving settings from a Setup view

The manifest may declare settings with just a key and type. Save ordinary settings with settings::set("greeting", settings::Value::Text("Hi".into())). The type must match the schema; numbers and choices obey their bounds and options, URLs must parse as complete http(s) addresses, and unknown keys are refused. Empty text restores a default. Every open view receives Event::SettingsChanged(Some(key)); None means a bulk refresh.

Secrets and settings used in net hosts or program patterns cannot be changed by the component. Place the host's field instead:

v_flex().child(setting_field("server").placeholder("https://example.com"))

Pitwall owns that field's value and saves it on Enter or blur. A valid URL updates the dynamic host of an already-granted network permission. An explicit network refusal stays refused. The field cannot edit secrets; unknown and secret keys show an error. Program execution is still planned. Test a field with tile.enter_setting("server-field", "https://example.com"); the harness validates and saves it without delivering an input event to the component.

When the user changes a setting, the tile hears Event::SettingsChanged(Some(key)) (None for a bulk refresh) and, by default, renders again. The form template signs each note with its "Signed as" setting, read while rendering:

let author = settings::text("author").unwrap_or_else(|| "me".into());

In tests, Harness::setting(key, value) and secret(key, value) start the tile with settings, and set_setting(key, value) changes one while it runs:

#[test]
fn a_note_needs_a_title_and_is_saved_signed() {
    let mut tile = Harness::build(env!("CARGO_MANIFEST_DIR")).setting("author", "Ana").open("main");
    tile.click_text("Save");
    assert!(tile.find_text("Give it a title.").is_some(), "{}", tile.text_snapshot());
    tile.type_into("title", "Standup").type_into("body", "Ship the beta");
    tile.click_text("Save");
    assert!(tile.find_text("Give it a title.").is_none());
    assert!(tile.find_text("by Ana").is_some());
    assert_eq!(tile.toasts(), vec![("Saved".to_string(), Tone::Good)]);
    let notes: serde_json::Value = tile.stored_json("notes").expect("stored");
    assert_eq!(notes[0]["title"], "Standup");
    // The setting changes in Settings: the form follows.
    tile.set_setting("author", Some("Bo"));
    assert!(tile.find_text("Signed as Bo").is_some());
}

Log

Each tile has a Log: open it from the extension's card in Settings → Extensions, or print it with pitwall extension log <id>. It also notes when the tile started, stopped or was reloaded. Pitwall keeps the newest 500 lines.

CallFor
log::debug(…)Detail for whoever is debugging the tile
log::info(…)Something worth knowing happened
log::warn(…)Something went wrong, and the tile carried on
log::error(…)Something failed

println! and eprintln! reach the same Log, as info and warnings. A line is at most 4 KiB; longer lines are cut. Pitwall adds its own notes, such as a slow call or a dropped toast.

In tests, log_text() gives the whole Log and logged(level, text) checks for a line.

UI

Requests about the tile's own views, in ui. They act only inside the tile's own area of the window.

CallDoes
ui::toast(text, tone)Shows a short message, labelled with the tile's name. Tone::Info, Good, Warn or Bad. At most 200 characters and 3 toasts a minute; more are dropped and noted in the Log
ui::open_view(tile)Opens one of the extension's tiles (an id from contributes.tiles), or focuses its view when one is open
ui::scroll_to(view, key_path)Scrolls the element at that key path into sight after the view's next render. The key path is the one cx.focus takes: keys from the root down, without the root's ("list/rows/n4")
ui::request_render(view)Renders the view again after this call; in a listener, cx.notify() is simpler
ui::put_image(name, &bytes)Hands Pitwall an image (PNG, JPEG, GIF, WebP or SVG, at most 8 MiB) for image_data(name) (Images). Kept until put again or dropped; at most 64 MiB for all of a tile's. Invalid when the bytes aren't one of those formats, TooLarge over a limit
ui::drop_image(name)Forgets an image put under name

The form template saves a note and says so in a toast:

self.notes.push(Note { title, body: self.body.trim().to_string(), by });
if let Err(e) = storage::set_json("notes", &self.notes) {
    self.error = Some(format!("It wasn't saved: {e}"));
    return;
}
(self.title, self.body, self.error) = (String::new(), String::new(), None);
ui::toast("Saved", Tone::Good);

In tests, toasts() lists the toasts and ui_requests() the other requests.

Network

net fetches from the hosts the manifest names, with the net permission (Permissions). Declare them with the reason:

"permissions": {
  "net": { "reason": "To read your builds from the CI server", "hosts": ["ci.example.com", "*.example.org"] }
}

A host is a name (api.example.com), a name with a port (api.example.com:8443), or *.example.org for its subdomains (not example.org itself). At most 32. Only https reaches them; http only to this computer (localhost, 127.0.0.1, [::1]), and only when the list names it with its port.

When the server is the user's own, name it by a url setting instead: "{setting:KEY}", where KEY is one of the extension's settings of type url.

"settings": [{ "key": "server", "type": "url", "label": "Server address", "required": true }],
"permissions": {
  "net": { "reason": "To read your builds from your CI server", "hosts": ["{setting:server}"] }
}

The tile may then reach the host and port of that setting's value: https://ci.example.com:8443/ allows ci.example.com:8443; http://127.0.0.1:8080 allows this computer on that port. Nothing is allowed while the setting is empty or isn't such an address. The permission screen shows it as "the server in Server address" and, once set, its host. When the user changes the setting, the grant follows the new host and the tile hears Event::GrantsChanged and Event::SettingsChanged(Some(key)). In the harness, Harness::build(…).setting("server", "https://ci.example.com") sets it, and .serve(|request, reply| …) answers the tile's requests from a fake server, at once or later (a long poll).

A request is made on the context, since its answer calls back into the tile:

let req = net::Request::get("https://ci.example.com/api/builds?limit=20").header("Accept", "application/json");
cx.fetch(req, |tile, answer, cx| {
    match answer.and_then(|r| r.json::<Vec<Build>>()) {
        Ok(builds) => tile.builds = builds,
        Err(e) => tile.error = Some(e.to_string()),
    }
    cx.notify();
})?;

cx.fetch returns a RequestId at once, or an error when the request is refused before anything is sent (Denied names the host). The answer comes later: Ok(Response) for any status (ok() is 200 to 299), or Err(net::Error): TimedOut, Failed (no connection), TooLarge, Denied (a redirect to a host not listed). cx.cancel_fetch(id) drops one.

Limit
At once8 requests
Request body8 MiB
Answer32 MiB
Time30 s, at most 120 s with .timeout(…)
Redirects5, each checked against the hosts again

Pitwall checks the address before looking up the name, and again on every redirect. It sends no cookies and no credentials of its own, and uses no proxy. There are no raw sockets.

In tests, Harness::respond(url, status, body) answers a request (the whole address, query included), respond_error(url, error) fails it, and nothing leaves the test; others get a 404. requests() lists what the tile sent. The tile still needs the grant (grant("net")) and the host in its manifest, as in Pitwall.

Database

sql is a SQLite database run by Pitwall, one per extension, kept outside its folder across restarts and updates. No permission: 100 MiB. A larger one, at most 2048 MiB, is asked for with the sql permission and granted with the extension, shown with its size: "sql": { "reason": "To keep a year of builds", "mib": 500 }.

Declare the schema as migrations, in order, and run them when the tile starts. Pitwall keeps the schema's version and runs each step not yet run in a transaction of its own:

const MIGRATIONS: &[&str] = &[
    "CREATE TABLE builds (id INTEGER PRIMARY KEY, name TEXT NOT NULL, state TEXT NOT NULL)",
    "ALTER TABLE builds ADD COLUMN url TEXT",
];

fn new(cx: &mut Cx<Self>) -> Self {
    if let Err(e) = sql::migrate(MIGRATIONS) {
        log::error(format!("the database couldn't be set up: {e}"));
    }
    // …
}
CallDoes
sql::execute(statement, params)Runs one statement; the rows it changed
sql::query(statement, params)Runs one query; its Rows (row.get::<i64>("n"), or by index)
sql::transaction(|| …)Runs the closure in a transaction: committed when it returns Ok, rolled back on Err
sql::migrate(steps)Runs the steps not run yet; the schema's version
sql::usage(), sql::quota()The bytes it takes and may take

Parameters are (), a tuple (("a note", 3)) or a Vec<sql::Value>; ? marks each place. A query returns at most 10 000 rows and 8 MiB; page with LIMIT. A write past the quota fails with TooLarge. A transaction lasts one call into the tile: one left open when the call returns is rolled back, with a line in the Log.

The database can't reach anything else: no ATTACH, no extensions, no PRAGMA that changes how the file is kept (table_info, foreign_keys and other read-only ones work). A statement still running at the call's deadline is stopped (Busy).

In tests the database is in the test's temporary folder; database() gives its file.

Notifications

notify::send(title, body) shows a notification, with the notify permission. It is the system's notification when you aren't looking at Pitwall (as for an agent that needs you) and a toast in Pitwall's window, with Open. At most 3 a minute; the same words within 10 minutes are shown once. A title is at most 80 characters, the text 200.

In tests, notifications() lists what it sent.

Opening a file or a page

Files and in-app pages need show; the external browser needs its own show.browser permission. Both start off until the user allows them.

CallDoes
show::file(path, line)Opens the file (a whole path) in Pitwall's editor, at the line when given
show::view(path, line)Shows the file in Pitwall's file viewer, scrolled to the line, as an agent's show_files does: with its git repository's tree (else its folder's) and git status, in the extension's own viewer window, which opens behind the front window without taking the keyboard. Later calls add tabs to it
show::web(url)Opens the page in a new web tile, in the extension's own browser store. https only, http only to this computer
show::browser(url)Opens the external browser, which may come forward. Requires the separate show.browser permission, off until allowed. Pitwall saves no web location and records no URL in Log, Activity or diagnostics; the browser controls its own history

None gives the tile anything back. In tests, ui_requests() lists them (OpenFile, OpenWeb, ViewFile).

Files in the project

A view is open in a project: its space's, the one of the agent it was opened next to, or the one whose sidebar menu opened it. files reaches that project's folder, and the extension's own files folder. A tile never names a folder of its own.

CallDoes
files::project(view)The view's project, Project { name, folder }, or None (no project, or neither files.read nor projects.read)
files::read(&root, path), read_textA file's bytes, or its text
files::stat(&root, path)An Entry: path, kind (File, Folder), size, modified (ms)
files::list(&root, folder, deep)The entries in a folder ("" for the root), every level down with deep, sorted by path
files::watch(&root, folder), unwatch(id)Follow a folder and everything under it: Event::FilesChanged { watch, paths }, changes close together in one event (a quarter second quiet, at most a second late)
files::write(&root, path, bytes), write_textWrite a file whole (made with its folders when missing, replaced at once, never half written)
files::create(&root, path, bytes)Write a new file; Exists when one is there
files::make_folder(&root, path), rename(&root, from, to)A folder with its parents; move a file or folder (Exists when the target is there)
files::delete(&root, path)To the Trash, in a project; for good, in its own folder

Root::project(view) is the view's project; Root::Data the extension's own files folder, kept across updates, at most 100 MiB, needing no permission. Reading a project (project, read, stat, list, watch) needs files.read; changing it needs files.write, which starts off. During an agent's show, present or read call, writes are refused.

Paths are relative, with / between parts. Pitwall refuses (NotAllowed, with why) an absolute path, .., a link that leads out of the root, anything in .git (never listed, read or changed), and a change to Pitwall's own .pitwall.json or .pitwall/. list and watch leave out what the project's .gitignore files and .git/info/exclude ignore; read and stat still reach those files by name. A file read or written is at most 8 MiB (TooLarge), a list at most 10 000 entries, and a tile has at most 8 watches.

let root = files::Root::project(view);
for e in files::list(&root, "docs", true)?.iter().filter(|e| e.path.ends_with(".md")) {
    let text = files::read_text(&root, &e.path)?;
    // …
}
let watch = files::watch(&root, "docs")?;

When the view moves to another project, or out of every project, the tile hears Event::ProjectChanged(view): its watches there have ended; read the new project. Every change to a project, and every refusal, is a line in the extension's Activity.

In tests, Harness::project("shop") starts the tile's view in a project folder of the test's, project_file(path, text) puts files in it, and .grant("files.read") grants it. Then write_project_file, remove_project_file and rename_project_file change it (the watches hear it at once), project_file(path) reads it back, trashed() lists what went to the Trash, watches() counts the watches, move_to_project(view, Some("api")) moves a view, and activity() lists its Activity lines.

Toolbar button

An extension may put one button in Pitwall's top bar, in a group of its own after the counts. Declare it in contributes.toolbar; the user can hide it, and an update never shows it again (Tiles and UI).

CallDoes
toolbar::set_badge(badge, tone)Its badge: Badge::None, Dot or Count(n); Tone::Normal or Attention. At most 4 changes a second
toolbar::set_project_badge(project, badge, tone)A project's badge, for a button with "scope": "project" (needs projects.read)
toolbar::set_tooltip(text)Its tooltip, at most 80 characters
toolbar::set_shown(shown)Hides or shows the button for a while (at most one change in 5 s); the user's Hide wins
toolbar::close_popover()Closes its popover

The badge shows only while the tile runs. With "badge": true, Pitwall keeps the tile running with no view open, so the badge stays current. A press runs its action; the tile hears Event::ToolbarClicked { project }. Its popover is a view of the tile, toolbar::POPOVER_VIEW: render it in render when view is that id.

In tests, toolbar() gives the badge, tooltip and whether the popover is open; click_toolbar(project) presses the button and click_in_popover(key) clicks inside the popover.

Programs and local servers

With the off-by-default programs permission, a component asks Pitwall to run a command once or keep a named process group running. Each exact resolved command asks Run, Always or Deny. programs::Command builds argv directly, with optional environment references and a folder under {data}. Completion is Event::ProgramFinished; supervised changes are Event::ProgramChanged. A supervised loopback listen address gives the component HTTP reach only while that approved program is running. Stop, revoke, off, update, removal and quit end that reach.

programs::download fetches a SHA-256-pinned HTTPS file to a new destination under {data}, optionally unpacking with the host's bounded readers. Running it still asks. See Programs and servers for manifest patterns, private one-shot output, limits, lifecycle and harness examples.

Its own server (legacy)

An extension with a service (a program Pitwall keeps running, such as the server its agents talk to) reaches that server from its tile without net (Servers in extensions):

CallDoes
service::info()Its state (Up, Starting, Off, NeedsInstall, Stopped, Failed), its address, its version, and why when it isn't up
service::url(path)The address with path, for cx.fetch; None when it doesn't listen
service::restart()Starts it again, as Restart on the card does
service::open_card()Opens the extension's card, where the user installs and starts it

The tile hears Event::ServiceChanged(info) when its state changes.

In tests, Harness::own_server("127.0.0.1:8790") says it is up there, and set_service(info) changes its state.

Agents, badges and questions

The agents' questions group: what an inbox-style tile needs to show questions from a service or from agents, have them answered in the floating control, and send an answer to an agent. The same rules as extensions' adapters have: the same permissions, limits and Activity.

Agents

With the agents.read permission, agents::list() gives every agent Pitwall shows, in the sidebar's order: its id, name, kind and kind_name ("Claude Code"), project (its folder), branch, state (Working, Blocked, Idle, Done, Stopped, Unknown), waiting_on_you (it is blocked on an approval or a question) and queued (items in its Next up). When that changes, the tile hears Event::AgentsChanged and reads them again; changes close together arrive as one.

With agents.queue, agents::queue_add(agent_id, text) puts text in an agent's Next up, marked "From <extension name>" on its "N queued" chip and in the popover it opens. It waits for the user's Send: Auto-send sends it only when the user lets the extension send without asking, in its card. At most 4 000 characters (TooLarge); at most 3 of the extension's items wait in one agent's Next up, and one is queued per agent every 10 seconds (Busy, with the reason in the Log).

let waiting: Vec<Agent> = agents::list()?.into_iter().filter(|a| a.waiting_on_you).collect();
agents::queue_add(&waiting[0].id, "Rebase on main and run the tests")?;

Nudging an agent when something happens

Use agents::queue_add to push an event notification to a specific agent. For example, when the extension receives a reply from its service, queue “A reply arrived for item 123; read it through the extension's tool.” The agent does not need to poll the extension to discover the event. Keep the message short, identify the item, and let the agent fetch the current details through the extension's tools.

Pitwall owns delivery through the agent's session. Extensions need no terminal scripts or tmux integration. A successful call means the message was accepted into Next up; it is not a delivery receipt or confirmation that the agent acted on it. Automatic delivery requires both the extension's send without asking opt-in and the agent's Auto-send setting. It waits until the running agent is Idle or Done and has settled; it does not interrupt Working agents or restart Stopped agents. The user can also send or remove the queued item manually.

Queue once for each relevant event, coalesce bursts, and respect the limits above. Do not repeatedly queue the same event while waiting for a reply. The extension still needs its own supported event source and runtime lifecycle; queue_add does not create a webhook receiver or keep an otherwise suspended extension running.

There is no SDK call for reading agents' terminals. Native Programs carry the user's OS authority, a separate trust decision described in Programs and servers.

Variables on agents

With the agents.env permission, agents::set_env(&[(name, value), …]) sets variables on the agents Pitwall starts from now on, in the projects the extension is on for (every project but those unticked on its card). The whole set each time, at most 16; &[] sets none. Each name must be one the permission lists (Permissions). A value is:

  • plain text,
  • one of its plain settings, {setting:KEY} (its value as the user set it, else its default), never a secret,
  • the agent's own identity, filled in for each agent: {agent_name}, {agent_id} (its session, kept across restarts) and {project} (its project's folder name).

A name it doesn't list, a secret, another placeholder or a brace is Invalid, with the reason in its Log, and the set stays as it was. Pitwall keeps the set across restarts and shows it on the extension's card. Agents already running keep what they started with: a new set or a changed setting makes them running agents that use an old setup, restarted as its card's "After its updates" setting says. Agents Pitwall didn't start never get them.

agents::set_env(&[("MY_SERVER_URL", "{setting:server}"), ("MY_SESSION", "{agent_id}")])?;

Badges

With "badges": true in contributes, badges::set(&[…]) puts a count or a few words on sidebar rows, beside Pitwall's own waiting badges: on an agent's row by its id (needs agents.read) or on a project's row by its folder (needs projects.read). The whole set each time; &[] clears them.

badges::set(&[Badge::count(Row::Agent(agent.id.clone()), 2).tone(Tone::Bad).tooltip("2 failing runs").open("main")])?;

A count is at most 9999, a note (Badge::note) at most 16 characters, a tooltip (shown after the extension's name) at most 120. open names one of the extension's tiles, opened by a click. At most 500 badges, and at most four sets a second are shown (the newest waits for its turn). A badge on a row the tile may not name is dropped and noted once in its Log. They go when the extension is turned off or its last tile closes.

Questions

With "asks": true in contributes, asks::set(&[…]) shows the tile's open questions in the floating control, after agents' own prompts, as an inbox's are: a card with who asks, the question, the suggestions, a field for the user's own words, Send, Decline and "Open <tile>". A blocking question comes first, marked "Waiting on you". The whole set each time; at most 50.

asks::set(&[Ask::new("deploy-42", "Deploy api to staging?")
    .title("Release 0.9")
    .from_agent(agent.id.clone())       // shown by its name; needs agents.read
    .suggest_with("Deploy", "Ship 0.9 to staging now")
    .suggest("Not now")
    .blocking()])?;

An answer arrives as Event::AskAnswered(Answer { id, picks, text, declined }), picks by place from 0. Reply with asks::reply(id, None) when it was taken, then send a set without the question; or with asks::reply(id, Some("why")) to refuse it: the card says "Not sent: why" and the user can answer again. Until the reply, the card says "Sending…".

A title is at most 200 characters, a question 2 000, a suggestion's label 80 and its description 200, and an ask has at most 8 suggestions; longer text is cut. Pitwall keeps the questions while the tile is hidden or let go to save memory, and an answer to a tile that was let go starts it again first.

Status

With "status": true in contributes, status::set(state, message) reports the extension's connection to its service, shown where an adapter's is: the pill on its card in Settings → Extensions ("Connecting", "Connected", "Signed out", "Error", with the message under it), the Connected step of its checklist, and the update's check that it connects again as it did before. state is State::Connecting, Ready, SignedOut (a credential is missing, wrong or expired) or Error; the message is at most 500 characters, usually empty when ready.

match api.check() {
    Ok(()) => status::set(status::State::Ready, ""),
    Err(e) if e.is_auth() => status::set(status::State::SignedOut, "The server refused the API key: paste a new one in Settings."),
    Err(e) => status::set(status::State::Error, &format!("Can't reach the server: {e}")),
}

Until its first report, and each time its component starts again, the card says "Connecting"; a component that stops says "Stopped", and Restart on the card starts it again. Report from a component that runs while the extension is on: with a toolbar button with "badge": true, Pitwall keeps it running with no view open. Without the contribution a call is ignored, with a line in the Log.

Send with take-back

TakeBack<T> holds what the user sent for a few seconds (5 by default, TakeBack::with_seconds(n) for 1 to 30) with a countdown and Undo, before the tile's own send runs: an answer, a message, anything the user may want back.

struct Desk { reply: String, sending: TakeBack<String> }

fn sending(d: &mut Desk) -> &mut TakeBack<String> { &mut d.sending }

// On Send:
let text = std::mem::take(&mut self.reply);
self.sending.hold(text, "Your reply", cx, sending, |d, text, cx| d.post(text, cx));
// In render: "Your reply: sending in 4 s", with Undo, which puts the text back.
.child(self.sending.view(cx, sending, |d, text, _| d.reply = text))

held() lists what waits, undo(id) and send_now(id) act on one by its id. Its countdown runs on the tile's timers: it stands still while the tile is hidden, and a test lets it pass with advance.

In tests

The harness has a fake Pitwall side: Harness::agent(agent("a1", "web")) (or waiting_agent) adds an agent, set_agents(…) changes them and sends AgentsChanged, queued() lists what the tile queued, badges() and asks() give its newest sets, answer(id, &[0]), answer_text(id, "…") and decline(id) answer, reply(id) says what the tile replied, agent_env() gives the variables it sets on agents now, and status() gives the status it reports now (None before its first).

let mut t = Harness::build(env!("CARGO_MANIFEST_DIR")).grant("agents.read").agent(waiting_agent("a2", "api")).open("main");
assert_eq!(t.asks()[0].from.as_deref(), Some("a2"));
t.answer("deploy", &[0]);
assert_eq!(t.reply("deploy"), Some(None));

Not provided

  • Direct OS file or process access from the component. Use files, storage, sql or the approved Programs capability.
  • Raw sockets, and the network beyond the hosts the manifest names.
  • A terminal-reading host API. Terminal contents can include secrets and prompts.
  • Other extensions' data, settings or secrets.
  • Unconditional background lifetime. Toolbar badges can keep a component running; a Programs grant also keeps it available, with hidden timers limited to once a second. Other hidden views follow the normal suspension lifecycle.

These limits describe the component sandbox and host APIs. Approved native Programs run as the OS user; the host API restrictions do not confine a helper's own file, socket or process access.

What comes later

PhaseServices
On demandGit in your projects, file pickers, the clipboard, starting agents, and more, each when a tile needs it