The woolshed module
Mods import Woolshed's live data and commands from the woolshed module. The full API is in woolshed.d.ts beside your installed guide.
Mods import the app's data and commands from "woolshed"; all of it is in woolshed.d.ts. Older mods that import from "herdr" get the same module and keep working. In short:
- Live data:
spaces()(each with its tabs, status, name, named, folder, machine, branch),machines()(name, null for this computer; layout:loading,ready, orunavailableon this connection; loading ends on the first read even if it fails, and offline machines are unavailable),agents()(status, app, space, tab, pinned, focused; "done" turns "idle" once someone looks at it on any client of its core),terminals()(every core terminal),focused(),layout(),theme()(every color by name: background (the terminals', cards), canvas (behind cards), chrome (sidebars, bars), surface, popover, raised, hover, selected, border, input (a stronger border), foreground, muted, dim, accent, accent_foreground, solid and solid_foreground (a primary button), selection, working, blocked, done, idle, unknown, ansi0..15; light and dark themes name the same ones),settings()(withdark: the appearance now),keys(),commands()(every app command, its arguments and what it does),layouts()(the layout names).focused().agentis the agent an agent block shows.focused().space/tabdescribe the current window context. With a layout terminal block focused,paneandshownare null;terminalandcwddescribe that block, not its source pane. Checkfocused()?.panebefore offering pane controls.panes()still lists only model panes; none is focused while a terminal block is. For composition navigation:run("pane.focus", {terminal: nextAddress}). Terminal copy/paste and implicit right-click routing follow the focused block. - Floating:
placement()(null unless this copy floats). - Act:
run(command, args). - Overlays:
openOverlay({ mod, props, kind: "dialog" | "popup" | "window", width, height, at, frame })returns an id; the mod getsprops().overlayand closes itself withcloseOverlay(id); Esc closes the top dialog or popup.frame: "none"drops Woolshed's border, corners and shadow so the mod draws its own.notify({ title, body, level, icon, timeout })posts a notification, drawn by thetoastmod. - Windows (
kind: "window"): stay open until closed, over the layout and under dialogs; a press the mod doesn't stop drags it (stop it on your controls, like a title bar's buttons), it stays where dropped, and the one pressed last is on top. Sized by content unlesswidth/height; atator centered.key: "name"remembers its spot (opening that key again replaces it);keep: truewith a key reopens it on the next start. A layout switch closes windows; kept ones come back with their layout. A window can hold a layout, terminals too: a terminal keeps its presses (selecting text), so give it a mod block to drag by, a title bar:openOverlay({ kind: "window", key: "t7", width: 600, height: 400, layout: { type: "column", children: [{ type: "block", size: { px: 28 }, content: { mod: "my-titlebar" } }, { type: "block", content: { terminal: "t7" } }] } }). - Machine:
exec(cmd, args, { cwd, on, timeout })(the user's real environment; use this, notprocess.run;on: space.machineruns there, omitted means local).timeoutis milliseconds, defaults to 30,000 and is capped at 600,000 (10 minutes), locally and remotely. It rejects on timeout, if the program cannot start or the machine cannot be reached.hc(args)(hc read <t>gives a terminal's text),home(),appHome(),playSound("done" | "blocked" | file).knownAgents({ on }): the agents people can start (programs.json'srun), most picked first, eachinstalledor not there (asked of the shell agents start in; a remote Unix machine's login/interactive shell when supported); start one withargv: agent.run.pickFolder({ prompt }): the system's folder picker (here only), resolves with the folder or null;pickFiles({ prompt })the file picker (several at once; none when cancelled).clipboardFiles(): files copied in the file manager, or a copied image (a screenshot) kept underappHome()/data/pasted; read it on an input'spaste_other. - Files:
readTextFile(path, { on })(here, or on that machine),writeTextFile(path, text, expected)(here only), andwatchFolder(dir)(here only; poll a remote space's folder): resolves with the changed paths the next time anything underdirchanges. On Linux, Git-ignored directories and Git objects are skipped, and trees above 4096 non-ignored directories reject the watch; use a timer fallback. macOS and Windows watch recursively, including ignored directories. A returned root path means refresh everything (the pending paths are bounded). Files also refreshes on its 10-second timer:cx.spawn(async (cx) => { for (;;) { await watchFolder(dir); this.reload(); cx.notify(); } }). notify({ ..., action: { name, args } }): the toast runs the command when clicked.buttons: [{ label, action }]adds buttons, each running its own command (the app's agent toasts use them for answers);placeis a line under the body.- This copy:
props(),shared(key)/setShared(key, value)(every mod sees it; setting re-renders all),nextCommand()(key commands for this mod:cx.spawn(async (cx) => { for (;;) { const c = await nextCommand(); …; cx.notify(); } })).
Mods are trusted code: commands and network access (including fetch) are unrestricted. Other built-ins: localStorage (per mod copy), console.log, fetch, import * as fs from "fs/promises" (read in home, write under ~/.config/woolshed).
Your agents read these same words: Woolshed writes this guide to ~/.config/woolshed/AGENTS.md on every start. In it, “you” is the agent and “the person” is you.