Overview
A persistent terminal and connected tools for your agent.
How it works#
- World
- Integrations, runtimes, and permissions for your agent.
- User
- Your application’s user ID, with their own connected accounts and any number of groups. User objects list the groups in
groupIds. - Session
- Persistent files and shell state for one user in one world. A session acts for at most one of the user’s groups, fixed when it is created and returned as
session.groupId. - Execution
- One command. Each session runs one command at a time.
More concepts#
- Workspace
- Your account: its worlds, users, API keys, integrations, and settings.
- API key
- A secret your backend sends with every request. A key can use the whole workspace; see Authentication.
- Integration
- A set of tools, such as GitHub or your own API, that commands call as
<integration> <tool>. It is added to the workspace, then turned on per world. - Group
- Users who share connections, such as the people at one of your customers. A user can belong to several groups; each session acts for one of them. See Connect a group.
- Mount
- A folder inside
/workspacethat Smallworld keeps for the whole workspace, one group, or one user, so files outlast a session. Agents read it freely; each kind of change is allowed, asked, or denied. See Mounts. - Connection
- A user’s or a group’s account at an integration, such as a GitHub login. A user’s calls use their own connection, or the connection of the session’s group when they have none. It works in every world that has the integration turned on.
- Connect session
- One attempt to create a user’s or a group’s connection through the hosted page. Your backend creates it.
- Tool call
- One call a command makes to an integration tool, with its arguments and result. A call that needs a decision waits as a pending tool approval.
- Policy
- Whether a tool runs (Allow), waits for approval (Ask), or is hidden from agents (Hidden). See Permissions.
- Playground
- A chat in the dashboard where an agent uses a world’s terminal and tools, so you can try them before writing code. It runs as a test user.
Run a command#
- Submit a command with your user ID. A session is created if needed.
- Save
session.idfor reuse andexecution.idto track the result. - Read executions that still run. Approve or deny pending tool calls, then read the execution again.
- Return stdout, stderr, and the exit code to your agent.
Approvals may occur more than once. If a response is lost, read the execution when you have its ID; otherwise do not resend automatically.
Permissions#
Each integration tool has a policy: allow runs it, ask waits for an approval, and deny hides it from agents. Policies are set at four levels:
- Workspace: each tool’s default. Read them or set a default through the API, or use the dashboard.
- World: overrides for every user in a World. List, set, or remove them.
- Group: overrides for every call in a group’s sessions, in every World. A group can also turn an integration off for its sessions. List, set, or remove them.
- User: overrides for one user in every World. Approving a tool call with
remember: truesaves an Allow here.
A group override beats a user override, which beats a World override, which beats the workspace default. The group is the one the session acts for: its overrides replace the user’s own in its sessions, also on the user’s own account. Hidden is a ceiling: a tool the workspace hides stays hidden in every World and for every user, a tool a World hides stays hidden there whatever the group’s or user’s override, and a tool a group hides stays hidden in its sessions. A turned-off integration denies every call.
To see or revoke a remembered Allow, list the user’s overrides and remove the one you no longer want. The next call follows the World or workspace policy again. A remembered Allow has no effect in sessions of a group that sets its own policy for the tool.
Base URL#
https://api.smallworld.sh/api/v1Call from your backend with an API key.
Errors#
Check the HTTP status and stable code. A successful request can still contain a command with a nonzero exit code.
{
"statusCode": 403,
"code": "ip_not_allowed",
"message": "The source IP address is not allowed by this account's security settings"
}
- Request bodies are JSON objects. A body of another content type gets
415 unsupported_media_type; malformed JSON, or JSON that isn’t an object, gets400 invalid_request. A POST without a body needs no Content-Type. - GET requests reject query parameters they don’t define with 400.
- A method a path doesn’t support gets
405 method_not_allowedwith anAllowheader. An unknown path gets404 not_found.
A tool call that ends without a result records why. Tool approvals lists each cause and its message.
Limits#
| Limit | Value |
|---|---|
| Active time per command | 60 seconds by default; set per workspace from 1 second to 5 minutes. Waiting for approvals and integration calls doesn’t count; sleep does. |
| Execution time per command | 1 hour, including integration calls. The clock pauses while waiting for approvals. |
| Returned stdout and stderr | 1 MiB each. Longer output is cut and truncated is true. |
| Output through pipes and redirects | 128 MiB per command |
| Commands run | 10,000 per command |
| Loop iterations | 10,000 per loop, seq, or yes |
| Files in /workspace | 64 MiB and 10,000 files and directories |
| Command text | 256 KiB (262,144 bytes) |
| Shell variables | 64 KiB |
| Tool result | 1 MiB |
| Integration call | 60 seconds. Custom integrations default to 30 seconds and allow 1–60. |
| Tool approval | Expires after 15 minutes by default; set per workspace from 5 minutes to 1 month (30 days). Each approval has its own deadline. |
| Commands running at once | 16 per workspace, including commands that have waited for an approval for less than five minutes; a command waiting longer is set aside and doesn’t count. Further commands wait in line and start in order as earlier ones finish. |
| Execution context | 4,096 bytes of JSON |
| Uploaded files | 100 files and 8 MiB of decoded content per execution, in a request of at most 12 MiB. With the session's files, they must fit the /workspace limits. |
| Returned file changes | Not truncated; bounded by the /workspace limits |
| Text and PDF reads | 8 MiB per input. PDF text starts on page 1. Select up to 5 pages and 24,000 characters per read. Use --offset to continue. |
| Image previews | Static previews fit within 10 million pixels and 8 MiB. Larger PNG and JPEG screenshots up to 32 million pixels are resized automatically. Static GIF and WebP must fit as supplied. PDF previews render one page at up to 144 DPI, within 2 million pixels and 4 MiB. |
| Selected output files | Up to 4 files totaling 64 MiB per execution. Use --as file to download original bytes. |
Change active time and approval timeout in Settings → Terminal. Changes apply to new executions. A command that reaches its active-time or one-hour execution limit ends as timed_out with exit code 124. A command waiting for an approval keeps waiting across a graceful API restart or deploy, and also across a crash once it has waited five minutes.
Terminal reference#
- Commands run in a virtual Bash with standard semantics.
pipefailis off, so a pipeline exits with its last command’s code. - Between commands in a session, files under
/workspace, the working directory, and shell variables persist, along with file modification times and permissions. Shell functions, aliases, and files outside/workspacedon’t. Files uploaded with an execution persist only withpersistInSession: true. /tmpexists and is empty at the start of every command, somktempworks. Like everything outside/workspace, it is gone by the next command.- Available commands include the common Unix tools (
awk,sed,grep,find,sort,xargs,tar,gzip,diff, and more),jq,yq,rg,xanfor CSV,sqlite3,html-to-markdown, and, when the world enables them,python3andjs-exec. Runls /usr/binfor the full list. Use enabled integration tools for network requests. The shell has nocurl,git,pip, ornodecommand. - Web Access provides
web search --query "…"andweb fetch --url https://example.comin Worlds that allow those tools. Fetch accepts a public HTTP or HTTPS URL, an optionalmethod(GETby default,HEAD,POST,PUT,PATCH,DELETE, orOPTIONS), a string map ofheaders, and a textbody. Its result hasstatus,statusText,headers,body, andurl. Useweb fetch --url https://example.com | jq -r .bodyto print the body. JavaScript can callawait tools.web.fetch({ url: "https://example.com" }). Fetch works without configuring a search provider. Each tool follows its own policies and approvals. - Fetch returns HTTP error and redirect responses with their status and body. It returns redirects directly, makes one attempt, and times out after 30 seconds. Request and response bodies are limited to 1 MiB each, and
GETandHEADreject a body. Fetch has thewritelabel because its methods can modify remote state. Caller-supplied headers and body appear in approvals and call history, including anAuthorizationheader when supplied. Inspectweb fetch --schemafor URL and header restrictions. - Every execution returns the files its command created, modified, or deleted under
/workspaceinexecution.fileChanges, unless the request asks for fewer. See Send and receive files. viewreads PDF pages and text, previews supported images, and selects original files for download. Useview --helpfor page, text, and output limits. Selected images and downloads appear inexecution.outputFiles.- Mounts are folders inside
/workspace, such as/workspace/docs, that Smallworld keeps for the whole workspace, a group, or one user. Reading them always works. A change their settings deny fails withPermission denied; changes that need approval are checked once per mount when the command ends, and the result is inexecution.mountChanges. HOME=/workspace,PATH,SHELL,USER, andLANGare always set.- stdout and stderr come back exactly as printed, including NUL bytes.
- Within one command, the clock starts when the command starts and moves only when a tool call returns and by
sleep.date,jq now, file modification times, and Python’stime.time()don’t advance while the command computes (injs-exec,Date.now()moves 1 ms per read), andtimereports about 0. Random values, such as$RANDOM,mktempnames, Python’srandomanduuid4, andMath.random(), differ between commands but repeat exactly within one, so a command that waited a long time for an approval continues exactly as it started. Python’stime.sleepwaits without moving the clock, so a Python loop that waits fortime.time()to pass a deadline runs until the active-time limit; use the shell’ssleepinstead. Python’stime.monotonic()andtime.perf_counter()follow real time.timeoutalso measures real time, so a command that relies ontimeoutcutting off asleepbefore a tool call that waits for approval may stop asexecution_replay_divergedwhen it continues after the approval. - Each command runs on its own, so a busy command never slows down another one. A command that needs more memory than one execution may use is stopped; it keeps none of its output or file changes, and stderr says why.
- A command that would take
/workspacepast its file limits keeps none of its file changes, and stderr says why. ItserrorCodeisexecution_file_changes_discardedandfileChangesis null. - Background jobs (
cmd &) aren’t supported; such a command is rejected with 400 before it runs. Reading/dev/zero,/dev/urandom, or/dev/randomfails, andyesstops with an error after 10,000 lines. - Brace expansion counts toward the 10,000-step limit for one command:
{1..5000}fits, a larger expansion fails. Ajqquery stops after 10,000 iterations, for example amaporreduceover more than 10,000 items. python3runs Python 3.13 compiled to WebAssembly with its standard library, exceptsqlite3,ssl,ctypes,lzma,zoneinfo,readline,curses,tkinter,venv,ensurepip, and the Unix modulesgrp,pwd,fcntl, andresource. There is no pip, network access, or subprocesses, and starting a thread withthreadingfails.- Python reads and writes files of at most 8 MiB. A larger read fails with
FileNotFoundErrorand a larger write withOSError: [Errno 29] I/O error. A file that isn’t closed explicitly fails only on exit, where Python reports the error on stderr but still exits 0, so usewith open(...). For larger data, pipe it through stdin and stdout. - In
js-exec,await tools.<integration>.<tool>(input)calls a tool; a denial or failure rejects. Calls a script makes before it next waits, such as underPromise.all, start when it waits and run at the same time, up to 8 at once, so an integration can receive several calls of one execution at once. Calls that need approval ask one at a time, in the order the script made them, and the allowed calls made with them run without waiting for that decision. A rejected call that is never awaited is ignored.setTimeoutandsetIntervalaren’t available. A hyphenated key also answers in camelCase (my-apiastools.myApi), andtools["my-api"]works too. - Discover enabled tools, then inspect their
--helpand--schema.
Pagination
World, group, and group member lists accept limit (1–100, default 50) and cursor. A session’s executions and tool calls accept limit from 1 to 50 (default 20). Pass nextCursor to the next request until it is null. A cursor works only for the list that returned it; a group member cursor only for its group.
Every other list returns all its items in one response, without a cursor: tools, tool approvals, tool policies, integrations, and connections. Narrow tool approvals with sessionId, executionId, and pendingOnly.