Skip to main content

Sprites

@josh/spritesv2026.09.11.3· 1d agoMODELS
01README

Swamp models for Fly.io Sprites. Run commands, read and write files, manage services and checkpoints, and control network access.

Installation

Install the extension in your Swamp repository:

swamp extension pull @josh/sprites

Usage

You need a Sprites organization token and an existing Swamp vault. These examples use a vault named sprites-secrets. The vault put command prompts for the token.

The create method below creates a remote Sprite; provider charges apply. To use an existing Sprite, set name to its name and run lookup instead.

swamp vault put sprites-secrets API_TOKEN
swamp model create @josh/sprites/sprite build-sprite \
  --global-arg name=build-worker \
  --global-arg 'token=${{ vault.get("sprites-secrets", "API_TOKEN") }}'
swamp model method run build-sprite create

The token determines the organization. Use separate model instances and vault keys for different organizations.

Check the Python version on the Sprite:

swamp model method run build-sprite exec --input '{"cmd":["python3","--version"]}'
swamp data get build-sprite execStdout

Define an HTTP service using the Sprite's saved name:

swamp model create @josh/sprites/service build-web \
  --global-arg 'sprite=${{ data.latest("build-sprite", "state").attributes.name }}' \
  --global-arg service_name=web \
  --global-arg 'token=${{ vault.get("sprites-secrets", "API_TOKEN") }}'
swamp model method run build-web put --input '{"service":{"cmd":"python3","args":["-m","http.server","8080"],"http_port":8080}}'

Check that the service responds at the Sprite's URL:

swamp model method run build-sprite probeUrl
swamp data get build-sprite probeUrl

probeUrl requires an HTTP 200 response and saves the response size and SHA-256 hash.

The Sprite model saves the remote ID during create or lookup. Later changes check that ID and refuse to act on a replacement Sprite with the same name. When you are done, inspect the saved ID and name before deleting the Sprite:

swamp model get build-sprite --json
swamp model method run build-sprite delete

Models

Model type Manages
@josh/sprites/checkpoint A Sprite checkpoint: create, look up, and restore.
@josh/sprites/connector A provider connection and its Sprite access policy.
@josh/sprites/organization Sprite and connector lists, plus operations across multiple Sprites.
@josh/sprites/service One service on a Sprite: configuration, start and stop, logs, and signals.
@josh/sprites/sprite One named Sprite: commands, files, policies, and networking.
@josh/sprites/task A hold that keeps a Sprite awake until it expires.

Inspect any model type's methods, arguments, and output schemas:

swamp model type describe @josh/sprites/sprite --json

File writes, command input (stdin), and HTTP gateway request bodies accept {"kind":"text","text":"hello\n"} or {"kind":"base64","base64":"AP8="}. Supply the contents directly; these methods do not read files from the Swamp host.

Sprite exec saves an exec record and binary execStdout and execStderr files. By default, a nonzero exit fails the method before it saves output. Set failOnNonZero: false to save the exit code and output instead.

Operational limits

Stored data and request limits

Store credentials in vaults and restrict access to the Swamp repository and server. Binary output files may contain application secrets and expire after seven days. A failed method can leave some files or records saved and others missing.

Responses have a default 64 MiB cap. Organization requests default to a 30-second timeout per request; other models default to five minutes. Set timeoutMs and maxResponseBytes in model global arguments to change these limits. After a failed change, check the remote resource before retrying.

Services and runtime changes

A successful Sprite upgrade or restart only means that the API accepted the request. Check the runtime to confirm the change took effect. After a service startup event, check that the application is ready to handle requests.

A stopped service can start again after reboot. Delete its definition to prevent that. To resume an explicitly stopped HTTP service, run service start; an incoming HTTP request alone will not start it.

Commands inside the Sprite

Some methods require programs inside the Sprite:

  • Service signal, Sprite listTasks, and task methods require /usr/bin/curl.
  • Sprite proxy, gatewayList, and gatewayRequest require /.sprite/bin/python3.
  • Starting a TTY session with an explicit terminal size through exec or controlExec also requires /.sprite/bin/python3.

Service, checkpoint, and task models save the Sprite's ID and reject a replacement with the same name on later calls. The organization token stays outside the Sprite.

Checkpoints, tasks, and connectors

Restoring a checkpoint replaces the writable filesystem overlay and leaves /tmp unchanged. Before restoring, inspect the checkpoint model and verify its saved Sprite ID and checkpoint ID.

Checkpoint creation saves the newest checkpoint returned by the API. Avoid concurrent checkpoint creation on the same Sprite: the model could save a checkpoint created by another caller.

Task holds expire after at most one hour. Reading a task or saving its state does not extend the hold. Use refresh to renew it or delete to release it early.

Connector policy updates replace the whole policy. Provisioning a connection alone does not grant Sprite access; an empty policy denies access.

Operations across multiple Sprites

Organization methods that act on multiple Sprites select them by prefix or labels when called. They process one Sprite at a time and continue after recording a failure. They use the current inventory without checking IDs saved by individual Sprite models. Before a bulk restart, service deletion, or policy change, run listSprites and verify the target names and IDs.

Each method saves its summary under the method name. Per-Sprite results use <method>-<sprite-id>, including service methods. Service results also store serviceName. Organization exec saves execStdout-<sprite-id> and execStderr-<sprite-id>. It records nonzero exits rather than failing the whole run.

Each command gets the organization model's timeoutMs, which defaults to 30 seconds. Raise it for slow commands; it limits each command, not the full run.

02Release Notes

Inline every public model schema so registry extraction sees complete global arguments, methods, resources, and files. Add a source-level gate that rejects shared schema references in exported contracts.

03Models6
extensions/models/checkpoint.tsv2026.09.11.1

Global Arguments

ArgumentTypeDescription
tokenstringOrganization token; use a vault reference.
baseUrl?url
timeoutMs?number
maxResponseBytes?number
spritestringName of the Sprite this belongs to.
namestringLocal slot name for a saved checkpoint id.
fn create(comment?: string)
Take a fresh checkpoint and point this slot at it; a bound slot is retaken and its old id stays in history
ArgumentTypeDescription
comment?string
fn get()
Read the checkpoint id saved in this slot
fn restore()
Restore the checkpoint id saved in this slot
fn lookup(checkpoint_id: string)
Adopt an existing checkpoint id into this slot
ArgumentTypeDescription
checkpoint_idstring
extensions/models/connector.tsv2026.09.11.1

Global Arguments

ArgumentTypeDescription
tokenstringOrganization token; use a vault reference.
baseUrl?url
timeoutMs?number
maxResponseBytes?number
namestringLocal instance name for this connection.
providerstring
fn createApiKey(api_key: string, access_policy?: object)
Create an API-key connection; refuse an already bound instance
ArgumentTypeDescription
api_keystringUse a vault reference for the provider credential.
access_policy?objectGrant every Sprite access; this overrides sprite_labels and name_prefix.
fn provision()
Provision a managed connection; refuse an already bound instance
fn authorize(scopes?: string, add_scopes?: string, redirect_uri?: string, state?: string)
Start provider OAuth authorization; refuse an already bound instance
ArgumentTypeDescription
scopes?stringComma-separated scopes API field that replaces the provider defaults.
add_scopes?stringComma-separated add_scopes API field added to an existing grant.
redirect_uri?string
state?stringOptional OAuth state API field. Sprites generates one when omitted.
fn callback(code: string, redirect_uri?: string, access_policy?: object)
Complete the saved pending OAuth authorization without automatic retries
ArgumentTypeDescription
codestring
redirect_uri?string
access_policy?objectGrant every Sprite access; this overrides sprite_labels and name_prefix.
fn get()
Read this saved organization connection
fn updatePolicy(access_policy?: object)
Replace this connection
ArgumentTypeDescription
access_policy?objectGrant every Sprite access; this overrides sprite_labels and name_prefix.
fn delete()
Delete this connection; an already absent connection succeeds
fn lookup(id: string)
Adopt an existing organization connection id
ArgumentTypeDescription
idstring
extensions/models/organization.tsv2026.09.11.1

Global Arguments

ArgumentTypeDescription
tokenstringOrganization token; use a vault reference.
baseUrl?url
timeoutMs?number
maxResponseBytes?number
fn exec(cmd: array, path?: string, dir?: string, env?: record, input?: discriminatedUnion, select?: object)
Run one command on every Sprite the selector matches over HTTP exec; a nonzero exit is recorded, not failed; stdout and stderr are saved per Sprite as execStdout-<sprite-id> and execStderr-<sprite-id>
ArgumentTypeDescription
cmdarrayProgram and argv, encoded as repeated cmd parameters.
path?string
dir?string
env?record
input?discriminatedUnion
select?objectEvery Sprite in the organization.
fn listSprites(prefix?: string)
Read every Sprite visible to the organization token
ArgumentTypeDescription
prefix?stringOnly include Sprite names with this prefix.
fn setNetworkPolicy(select?: object, policy?: object)
Replace the network policy on every Sprite the selector matches; a failed Sprite is recorded and the rest continue; each Sprite
ArgumentTypeDescription
select?objectEvery Sprite in the organization.
policy?object
fn setPrivilegesPolicy(select?: object, policy?: object)
Set the privileges policy on every Sprite the selector matches; a failed Sprite is recorded and the rest continue; each Sprite
ArgumentTypeDescription
select?objectEvery Sprite in the organization.
policy?object
fn setResourcesPolicy(select?: object, policy?: object)
Set the resources policy on every Sprite the selector matches; a failed Sprite is recorded and the rest continue; each Sprite
ArgumentTypeDescription
select?objectEvery Sprite in the organization.
policy?object
fn deletePrivilegesPolicy(select?: object)
Remove the privileges policy from every Sprite the selector matches; a failed Sprite is recorded and the rest continue; each Sprite
ArgumentTypeDescription
select?objectEvery Sprite in the organization.
fn deleteResourcesPolicy(select?: object)
Remove the resources policy from every Sprite the selector matches; a failed Sprite is recorded and the rest continue; each Sprite
ArgumentTypeDescription
select?objectEvery Sprite in the organization.
fn getNetworkPolicy(select?: object)
Read the network policy from every Sprite the selector matches; each Sprite
ArgumentTypeDescription
select?objectEvery Sprite in the organization.
fn getPrivilegesPolicy(select?: object)
Read the privileges policy from every Sprite the selector matches; each Sprite
ArgumentTypeDescription
select?objectEvery Sprite in the organization.
fn getResourcesPolicy(select?: object)
Read the resources policy from every Sprite the selector matches; each Sprite
ArgumentTypeDescription
select?objectEvery Sprite in the organization.
fn upgrade(select?: object, version?: string)
Request a runtime upgrade on every Sprite the selector matches; success only records provider acceptance; each Sprite
ArgumentTypeDescription
select?objectEvery Sprite in the organization.
version?string
fn restart(select?: object)
Request a restart on every Sprite the selector matches; success only records provider acceptance; each Sprite
ArgumentTypeDescription
select?objectEvery Sprite in the organization.
fn createCheckpoint(select?: object, comment?: string)
Take a checkpoint on every Sprite the selector matches; each Sprite
ArgumentTypeDescription
select?objectEvery Sprite in the organization.
comment?string
fn putService(select?: object, service_name: string, service?: object, duration?: string)
Create or update the named service on every Sprite the selector matches; each Sprite
ArgumentTypeDescription
select?objectEvery Sprite in the organization.
service_namestring
service?object
duration?string
fn startService(select?: object, service_name: string, duration?: string)
Start the named service on every Sprite the selector matches; each Sprite
ArgumentTypeDescription
select?objectEvery Sprite in the organization.
service_namestring
duration?string
fn stopService(select?: object, service_name: string, timeout?: string)
Stop the named service on every Sprite the selector matches; each Sprite
ArgumentTypeDescription
select?objectEvery Sprite in the organization.
service_namestring
timeout?string
fn restartService(select?: object, service_name: string, duration?: string)
Restart the named service on every Sprite the selector matches; each Sprite
ArgumentTypeDescription
select?objectEvery Sprite in the organization.
service_namestring
duration?string
fn deleteService(select?: object, service_name: string)
Delete the named service on every Sprite the selector matches; each Sprite
ArgumentTypeDescription
select?objectEvery Sprite in the organization.
service_namestring
fn listConnectors(provider?: string)
List organization connectors
ArgumentTypeDescription
provider?string

Files

spriteExecStdout— Operation bytes; may contain application secrets
extensions/models/service.tsv2026.09.11.1

Global Arguments

ArgumentTypeDescription
tokenstringOrganization token; use a vault reference.
baseUrl?url
timeoutMs?number
maxResponseBytes?number
spritestringName of the Sprite this belongs to.
service_namestringService name on that Sprite.
fn put(service?: object, duration?: string)
Create or update this service, then save its definition
ArgumentTypeDescription
service?object
duration?string
fn get()
Read this service and save it
fn start(duration?: string)
Start this service
ArgumentTypeDescription
duration?string
fn stop(timeout?: string)
Stop this service
ArgumentTypeDescription
timeout?string
fn restart(duration?: string)
Restart this service
ArgumentTypeDescription
duration?string
fn logs(lines?: number, duration?: string)
Read a bounded portion of this service
ArgumentTypeDescription
lines?number
duration?string
fn signal(signal: string)
Send a signal to this service
ArgumentTypeDescription
signalstring
fn delete()
Delete this service; an already absent service succeeds
extensions/models/sprite.tsv2026.09.11.1

Global Arguments

ArgumentTypeDescription
tokenstringOrganization token; use a vault reference.
baseUrl?url
timeoutMs?number
maxResponseBytes?number
namestringSprite name within the token's organization.
fn create(config?: object, environment?: record, url_settings?: object, labels?: array, wait_for_capacity?: boolean, runtime?: enum)
Create the configured Sprite
ArgumentTypeDescription
config?object
environment?record
url_settings?object
labels?array
wait_for_capacity?boolean
runtime?enum
fn lookup()
Read the configured Sprite
fn update(url_settings?: object, labels?: array)
Update the configured Sprite
ArgumentTypeDescription
url_settings?object
labels?array
fn upgrade(version?: string)
Request a runtime upgrade; success only acknowledges provider acceptance
ArgumentTypeDescription
version?string
fn restart()
Request a restart of the machine backing this Sprite
fn probeUrl()
Check the verified Sprite root URL and fingerprint its response
fn delete()
Delete the configured Sprite
fn listCheckpoints()
List Sprite checkpoints
fn controlExec(operations?: array)
Run bounded sequential exec operations over one persistent WebSocket
ArgumentTypeDescription
operations?arrayProgram and argv, encoded as repeated cmd parameters.
fn exec(cmd: array, path?: string, dir?: string, env?: record, input?: discriminatedUnion, failOnNonZero?: boolean, tty?: boolean, rows?: number, cols?: number, detachable?: boolean, cc?: boolean, max_run_after_disconnect?: string, closeStdin?: boolean, actions?: array, detachAfterMs?: number)
Execute a command over WebSocket with binary output and optional TTY controls
ArgumentTypeDescription
cmdarrayProgram and argv, encoded as repeated cmd parameters.
path?string
dir?string
env?record
input?discriminatedUnion
failOnNonZero?boolean
tty?boolean
rows?number
cols?number
detachable?boolean
cc?boolean
max_run_after_disconnect?string
closeStdin?boolean
actions?array
detachAfterMs?numberSave session identity and disconnect after this duration instead of waiting for exit.
fn attach(session_id: string, input?: discriminatedUnion, failOnNonZero?: boolean, tty?: boolean, rows?: number, cols?: number, detachable?: boolean, cc?: boolean, max_run_after_disconnect?: string, closeStdin?: boolean, actions?: array, detachAfterMs?: number)
Attach to an existing exec session and exchange input, output, and controls
ArgumentTypeDescription
session_idstring
input?discriminatedUnion
failOnNonZero?boolean
tty?boolean
rows?number
cols?number
detachable?boolean
cc?boolean
max_run_after_disconnect?string
closeStdin?boolean
actions?array
detachAfterMs?numberSave session identity and disconnect after this duration instead of waiting for exit.
fn execHttp(cmd: array, path?: string, dir?: string, env?: record, input?: discriminatedUnion, failOnNonZero?: boolean)
Execute over HTTP/1.1 while preserving provider chunk framing
ArgumentTypeDescription
cmdarrayProgram and argv, encoded as repeated cmd parameters.
path?string
dir?string
env?record
input?discriminatedUnion
failOnNonZero?boolean
fn listSessions()
List exec sessions
fn killSession(session_id: string, signal?: string, timeout?: string)
Kill an exec session
ArgumentTypeDescription
session_idstring
signal?string
timeout?string
fn listFiles(workingDir?: string, path: string, recursive?: boolean, pattern?: string)
List a Sprite directory
ArgumentTypeDescription
workingDir?string
pathstring
recursive?boolean
pattern?string
fn readFile(workingDir?: string, path: string)
Read raw bytes from a Sprite file
ArgumentTypeDescription
workingDir?string
pathstring
fn writeFile(workingDir?: string, path: string, content: discriminatedUnion, mode?: string, mkdir?: boolean)
Write raw bytes to a Sprite file
ArgumentTypeDescription
workingDir?string
pathstring
contentdiscriminatedUnion
mode?string
mkdir?boolean
fn deleteFile(workingDir?: string, path: string, recursive?: boolean, asRoot?: boolean)
Delete a Sprite file or directory
ArgumentTypeDescription
workingDir?string
pathstring
recursive?boolean
asRoot?boolean
fn copyFile(source: string, dest: string, preserveAttrs?: boolean, workingDir?: string, recursive?: boolean, asRoot?: boolean)
Copy a Sprite file or directory
ArgumentTypeDescription
sourcestring
deststring
preserveAttrs?boolean
workingDir?string
recursive?boolean
asRoot?boolean
fn renameFile(source: string, dest: string, workingDir?: string, asRoot?: boolean)
Rename a Sprite file or directory
ArgumentTypeDescription
sourcestring
deststring
workingDir?string
asRoot?boolean
fn chmodFile(workingDir?: string, path: string, recursive?: boolean, asRoot?: boolean, mode: string)
Change Sprite file permissions
ArgumentTypeDescription
workingDir?string
pathstring
recursive?boolean
asRoot?boolean
modestring
fn chownFile(workingDir?: string, path: string, recursive?: boolean, asRoot?: boolean, uid?: number, gid?: number)
Change Sprite file ownership
ArgumentTypeDescription
workingDir?string
pathstring
recursive?boolean
asRoot?boolean
uid?number
gid?number
fn watch(paths: array, recursive?: boolean, workingDir?: string, durationMs: number, maxEvents?: number)
Observe acknowledged Sprite filesystem events for a bounded duration
ArgumentTypeDescription
pathsarray
recursive?boolean
workingDir?string
durationMsnumber
maxEvents?number
fn getNetworkPolicy()
Read the Sprite network policy
fn setNetworkPolicy(rules?: array)
Replace the Sprite network policy
ArgumentTypeDescription
rules?array
fn getPrivilegesPolicy()
Read the Sprite privilege policy
fn setPrivilegesPolicy(profile?: enum, devices?: array, noNewPrivileges?: boolean)
Set the Sprite privilege policy
ArgumentTypeDescription
profile?enum
devices?array
noNewPrivileges?boolean
fn deletePrivilegesPolicy()
Remove the Sprite privilege policy
fn getResourcesPolicy()
Read the Sprite resource policy
fn setResourcesPolicy(memory?: object)
Set the Sprite resource policy
ArgumentTypeDescription
memory?object
fn deleteResourcesPolicy()
Remove the Sprite resource policy
fn watchPorts(durationMs: number, maxEvents?: number)
Observe a Sprite listening-port snapshot and bounded open/close notifications
ArgumentTypeDescription
durationMsnumber
maxEvents?numberMaximum incremental notifications; initial snapshot entries do not count toward this limit.
fn proxy(localPort: number, host: string, port: number, durationMs: number, maxConnections?: number)
Run a bounded loopback-only TCP proxy through the Sprite
ArgumentTypeDescription
localPortnumberRequired port bound only on the IPv4 loopback interface.
hoststringRemote host reached from inside the Sprite.
portnumberRemote TCP port reached from inside the Sprite.
durationMsnumber
maxConnections?number
fn listServices()
List configured Sprite services
fn listTasks()
List active task holds through the Sprite management socket
fn gatewayList()
Discover connector access from inside the configured Sprite
fn gatewayRequest(provider: string, connection_id: string, providerPath?: string)
Relay one provider path through a configured Sprite connector
ArgumentTypeDescription
providerstring
connection_idstring
providerPath?string

Files

controlExecStdout— Operation bytes; may contain application secrets
controlExecStderr— Operation bytes; may contain application secrets
execStdout— Operation bytes; may contain application secrets
execStderr— Operation bytes; may contain application secrets
attachStdout— Operation bytes; may contain application secrets
attachStderr— Operation bytes; may contain application secrets
execHttpStdout— Operation bytes; may contain application secrets
execHttpStderr— Operation bytes; may contain application secrets
readFile— Operation bytes; may contain application secrets
extensions/models/task.tsv2026.09.11.1

Global Arguments

ArgumentTypeDescription
tokenstringOrganization token; use a vault reference.
baseUrl?url
timeoutMs?number
maxResponseBytes?number
spritestringName of the Sprite this belongs to.
namestring
fn create(expire: union)
Create a task hold; an existing name fails rather than being refreshed
ArgumentTypeDescription
expireunion
fn get()
Read an active task hold and save it
fn refresh(expire: union)
Refresh this task hold, or create it if absent
ArgumentTypeDescription
expireunion
fn delete()
Release this task hold; an already absent task succeeds
04Previous Versions2
2026.09.11.2

Added 1, removed 6 models

2026.09.11.1
05Stats
A
100 / 100
Downloads
0
Archive size
262.7 KB
  • Has README or module doc2/2earned
  • README has a code example1/1earned
  • README is substantive1/1earned
  • Most symbols documented1/1earned
  • No slow types (deprecated)1/1earned
  • Dependencies pass trust audit2/2earned
  • Has description1/1earned
  • Platform support declared (or universal)2/2earned
  • License declared1/1earned
  • Verified public repository2/2earned
06Platforms
07Labels