Skip to content
Overview

Overview

A persistent terminal and connected tools for your agent.

How it works#

Your agentYour backendA world
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 /workspace that 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#

  1. Submit a command with your user ID. A session is created if needed.
  2. Save session.id for reuse and execution.id to track the result.
  3. Read executions that still run. Approve or deny pending tool calls, then read the execution again.
  4. 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: true saves 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/v1

Call 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.

Error response
{
  "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, gets 400 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_allowed with an Allow header. An unknown path gets 404 not_found.

A tool call that ends without a result records why. Tool approvals lists each cause and its message.

Limits#

LimitValue
Active time per command60 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 command1 hour, including integration calls. The clock pauses while waiting for approvals.
Returned stdout and stderr1 MiB each. Longer output is cut and truncated is true.
Output through pipes and redirects128 MiB per command
Commands run10,000 per command
Loop iterations10,000 per loop, seq, or yes
Files in /workspace64 MiB and 10,000 files and directories
Command text256 KiB (262,144 bytes)
Shell variables64 KiB
Tool result1 MiB
Integration call60 seconds. Custom integrations default to 30 seconds and allow 1–60.
Tool approvalExpires 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 once16 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 context4,096 bytes of JSON
Uploaded files100 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 changesNot truncated; bounded by the /workspace limits
Text and PDF reads8 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 previewsStatic 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 filesUp 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. pipefail is 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 /workspace don’t. Files uploaded with an execution persist only with persistInSession: true.
  • /tmp exists and is empty at the start of every command, so mktemp works. 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, xan for CSV, sqlite3, html-to-markdown, and, when the world enables them, python3 and js-exec. Run ls /usr/bin for the full list. Use enabled integration tools for network requests. The shell has no curl, git, pip, or node command.
  • Web Access provides web search --query "…" and web fetch --url https://example.com in Worlds that allow those tools. Fetch accepts a public HTTP or HTTPS URL, an optional method (GET by default, HEAD, POST, PUT, PATCH, DELETE, or OPTIONS), a string map of headers, and a text body. Its result has status, statusText, headers, body, and url. Use web fetch --url https://example.com | jq -r .body to print the body. JavaScript can call await 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 GET and HEAD reject a body. Fetch has the write label because its methods can modify remote state. Caller-supplied headers and body appear in approvals and call history, including an Authorization header when supplied. Inspect web fetch --schema for URL and header restrictions.
  • Every execution returns the files its command created, modified, or deleted under /workspace in execution.fileChanges, unless the request asks for fewer. See Send and receive files.
  • view reads PDF pages and text, previews supported images, and selects original files for download. Use view --help for page, text, and output limits. Selected images and downloads appear in execution.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 with Permission denied; changes that need approval are checked once per mount when the command ends, and the result is in execution.mountChanges.
  • HOME=/workspace, PATH, SHELL, USER, and LANG are 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’s time.time() don’t advance while the command computes (in js-exec, Date.now() moves 1 ms per read), and time reports about 0. Random values, such as $RANDOM, mktemp names, Python’s random and uuid4, and Math.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’s time.sleep waits without moving the clock, so a Python loop that waits for time.time() to pass a deadline runs until the active-time limit; use the shell’s sleep instead. Python’s time.monotonic() and time.perf_counter() follow real time. timeout also measures real time, so a command that relies on timeout cutting off a sleep before a tool call that waits for approval may stop as execution_replay_diverged when 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 /workspace past its file limits keeps none of its file changes, and stderr says why. Its errorCode is execution_file_changes_discarded and fileChanges is null.
  • Background jobs (cmd &) aren’t supported; such a command is rejected with 400 before it runs. Reading /dev/zero, /dev/urandom, or /dev/random fails, and yes stops 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. A jq query stops after 10,000 iterations, for example a map or reduce over more than 10,000 items.
  • python3 runs Python 3.13 compiled to WebAssembly with its standard library, except sqlite3, ssl, ctypes, lzma, zoneinfo, readline, curses, tkinter, venv, ensurepip, and the Unix modules grp, pwd, fcntl, and resource. There is no pip, network access, or subprocesses, and starting a thread with threading fails.
  • Python reads and writes files of at most 8 MiB. A larger read fails with FileNotFoundError and a larger write with OSError: [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 use with 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 under Promise.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. setTimeout and setInterval aren’t available. A hyphenated key also answers in camelCase (my-api as tools.myApi), and tools["my-api"] works too.
  • Discover enabled tools, then inspect their --help and --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.